<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; 2005 &#8211; Find Tables With Foreign Key Constraint in Database</title>
	<atom:link href="http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Fri, 10 Feb 2012 04:35:14 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: somasundaram</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-203680</link>
		<dc:creator><![CDATA[somasundaram]]></dc:creator>
		<pubDate>Thu, 24 Nov 2011 13:11:18 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-203680</guid>
		<description><![CDATA[i need to know the list of keys used in SQl server 2005.. plz help me anybody…]]></description>
		<content:encoded><![CDATA[<p>i need to know the list of keys used in SQl server 2005.. plz help me anybody…</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ram singh</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-128247</link>
		<dc:creator><![CDATA[ram singh]]></dc:creator>
		<pubDate>Mon, 11 Apr 2011 10:03:18 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-128247</guid>
		<description><![CDATA[@TOM i m writting query to create table with fk.

CREATE TABLE ORDERS
(Order_ID integer primary key,
Order_Date datetime,
Customer_SID integer references CUSTOMER(SID),
Amount double);]]></description>
		<content:encoded><![CDATA[<p>@TOM i m writting query to create table with fk.</p>
<p>CREATE TABLE ORDERS<br />
(Order_ID integer primary key,<br />
Order_Date datetime,<br />
Customer_SID integer references CUSTOMER(SID),<br />
Amount double);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ram singh</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-128244</link>
		<dc:creator><![CDATA[ram singh]]></dc:creator>
		<pubDate>Mon, 11 Apr 2011 09:47:51 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-128244</guid>
		<description><![CDATA[@TOM  i m writting  query to create table with fk.


CREATE TABLE ORDERS
(Order_ID integer primary key,
Order_Date datetime,
Customer_SID integer references CUSTOMER(SID),
Amount double);]]></description>
		<content:encoded><![CDATA[<p>@TOM  i m writting  query to create table with fk.</p>
<p>CREATE TABLE ORDERS<br />
(Order_ID integer primary key,<br />
Order_Date datetime,<br />
Customer_SID integer references CUSTOMER(SID),<br />
Amount double);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sheetalkumar</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-122866</link>
		<dc:creator><![CDATA[sheetalkumar]]></dc:creator>
		<pubDate>Fri, 11 Mar 2011 12:24:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-122866</guid>
		<description><![CDATA[thanks you also say rigth and help ful solution]]></description>
		<content:encoded><![CDATA[<p>thanks you also say rigth and help ful solution</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mohamed Bakr</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-109876</link>
		<dc:creator><![CDATA[Mohamed Bakr]]></dc:creator>
		<pubDate>Fri, 07 Jan 2011 10:53:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-109876</guid>
		<description><![CDATA[Thank You.]]></description>
		<content:encoded><![CDATA[<p>Thank You.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chakri :-)</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-100283</link>
		<dc:creator><![CDATA[Chakri :-)]]></dc:creator>
		<pubDate>Tue, 16 Nov 2010 07:01:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-100283</guid>
		<description><![CDATA[k]]></description>
		<content:encoded><![CDATA[<p>k</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: clement</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-83124</link>
		<dc:creator><![CDATA[clement]]></dc:creator>
		<pubDate>Thu, 05 Aug 2010 13:09:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-83124</guid>
		<description><![CDATA[Thank you for these codes but i need your help seriously

The codes only display the column names but the foreign keys ar not displayed.

is there something i need to turn on?]]></description>
		<content:encoded><![CDATA[<p>Thank you for these codes but i need your help seriously</p>
<p>The codes only display the column names but the foreign keys ar not displayed.</p>
<p>is there something i need to turn on?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hbunny</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-71208</link>
		<dc:creator><![CDATA[hbunny]]></dc:creator>
		<pubDate>Mon, 17 May 2010 07:51:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-71208</guid>
		<description><![CDATA[Thank you, not only for this post, but for your entire blog, it helped me a lot...]]></description>
		<content:encoded><![CDATA[<p>Thank you, not only for this post, but for your entire blog, it helped me a lot&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Felipe Zapata</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-64164</link>
		<dc:creator><![CDATA[Felipe Zapata]]></dc:creator>
		<pubDate>Wed, 31 Mar 2010 17:22:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-64164</guid>
		<description><![CDATA[Thanks a lot, I needed that!]]></description>
		<content:encoded><![CDATA[<p>Thanks a lot, I needed that!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: binni</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-58393</link>
		<dc:creator><![CDATA[binni]]></dc:creator>
		<pubDate>Thu, 10 Dec 2009 09:48:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-58393</guid>
		<description><![CDATA[Hello,

How can i get unique key constains of table1.]]></description>
		<content:encoded><![CDATA[<p>Hello,</p>
<p>How can i get unique key constains of table1.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zia Rizvi</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-52782</link>
		<dc:creator><![CDATA[Zia Rizvi]]></dc:creator>
		<pubDate>Fri, 05 Jun 2009 21:42:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-52782</guid>
		<description><![CDATA[Excellent query. I was thrown into the project to work on somebody else&#039;s database design. I was supposed to right a data export procedure and this script CAME SO HANDY so find all the keys and the to right the stored procedure that return the data i want. Iit would have been impossible to find the relationships and then develop the procedure. AWESOME AWESOME!!!!!!!!!!!!!!]]></description>
		<content:encoded><![CDATA[<p>Excellent query. I was thrown into the project to work on somebody else&#8217;s database design. I was supposed to right a data export procedure and this script CAME SO HANDY so find all the keys and the to right the stored procedure that return the data i want. Iit would have been impossible to find the relationships and then develop the procedure. AWESOME AWESOME!!!!!!!!!!!!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-51043</link>
		<dc:creator><![CDATA[Mark]]></dc:creator>
		<pubDate>Thu, 16 Apr 2009 15:13:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-51043</guid>
		<description><![CDATA[Dude that rocks! You saved me a lot of frustation. Thank you. Thank you.]]></description>
		<content:encoded><![CDATA[<p>Dude that rocks! You saved me a lot of frustation. Thank you. Thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER - 2005 Find Table without Clustered Index - Find Table with no Primary Key Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-49762</link>
		<dc:creator><![CDATA[SQL SERVER - 2005 Find Table without Clustered Index - Find Table with no Primary Key Journey to SQL Authority with Pinal Dave]]></dc:creator>
		<pubDate>Mon, 23 Mar 2009 10:59:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-49762</guid>
		<description><![CDATA[[...] Related Post: SQL SERVER - 2005 - Find Tables With Primary Key Constraint in Database SQL SERVER - 2005 - Find Tables With Foreign Key Constraint in Database  [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Related Post: SQL SERVER &#8211; 2005 &#8211; Find Tables With Primary Key Constraint in Database SQL SERVER &#8211; 2005 &#8211; Find Tables With Foreign Key Constraint in Database  [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ravi</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-48238</link>
		<dc:creator><![CDATA[Ravi]]></dc:creator>
		<pubDate>Fri, 06 Mar 2009 09:35:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-48238</guid>
		<description><![CDATA[It&#039;s really very good script.it is very unique and useful script.keep it up pinal.You are doing very well job.]]></description>
		<content:encoded><![CDATA[<p>It&#8217;s really very good script.it is very unique and useful script.keep it up pinal.You are doing very well job.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER - 2008 - Find Relationship of Foreign Key and Primary Key using T-SQL - Find Tables With Foreign Key Constraint in Database Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-47513</link>
		<dc:creator><![CDATA[SQL SERVER - 2008 - Find Relationship of Foreign Key and Primary Key using T-SQL - Find Tables With Foreign Key Constraint in Database Journey to SQL Authority with Pinal Dave]]></dc:creator>
		<pubDate>Thu, 26 Feb 2009 12:36:27 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-47513</guid>
		<description><![CDATA[[...] Key and Foreign Key relationship using T-SQL, I came across my own blog article written earlier SQL SERVER - 2005 - Find Tables With Foreign Key Constraint in Database. It is really handy script and not found written on line anywhere. This is one really unique script [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Key and Foreign Key relationship using T-SQL, I came across my own blog article written earlier SQL SERVER &#8211; 2005 &#8211; Find Tables With Foreign Key Constraint in Database. It is really handy script and not found written on line anywhere. This is one really unique script [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQLAuthority News - Best Articles on SQLAuthority.com Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-47245</link>
		<dc:creator><![CDATA[SQLAuthority News - Best Articles on SQLAuthority.com Journey to SQL Authority with Pinal Dave]]></dc:creator>
		<pubDate>Tue, 24 Feb 2009 12:10:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-47245</guid>
		<description><![CDATA[[...] SQL SERVER - 2005 - Find Tables With Foreign Key Constraint in Database [...]]]></description>
		<content:encoded><![CDATA[<p>[...] SQL SERVER &#8211; 2005 &#8211; Find Tables With Foreign Key Constraint in Database [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sharmila</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-45573</link>
		<dc:creator><![CDATA[Sharmila]]></dc:creator>
		<pubDate>Tue, 13 Jan 2009 12:17:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-45573</guid>
		<description><![CDATA[Hi, ur articles always found very useful. thanks.  I hv one query.. i hv constraint on my master table, but there are excess data in my master, which not yet used in sub tables. I want to delete master data which is not used in subtable. Is it possible to delete thru sql? i m using sql 2005.

thanks]]></description>
		<content:encoded><![CDATA[<p>Hi, ur articles always found very useful. thanks.  I hv one query.. i hv constraint on my master table, but there are excess data in my master, which not yet used in sub tables. I want to delete master data which is not used in subtable. Is it possible to delete thru sql? i m using sql 2005.</p>
<p>thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jan Vandenpanhuyzen</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-42684</link>
		<dc:creator><![CDATA[Jan Vandenpanhuyzen]]></dc:creator>
		<pubDate>Thu, 11 Sep 2008 11:27:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-42684</guid>
		<description><![CDATA[George,

I&#039;ve a script that does the same but is a little less complicated I think:

SELECT TABLE_NAME, TABLE_SCHEMA, COLUMN_NAME, CONSTRAINT_NAME FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE CCU
INNER JOIN sys.foreign_keys f
ON CCU.TABLE_NAME = object_name(parent_object_id) and CONSTRAINT_NAME = f.name
WHERE f.type = &#039;F&#039;
AND NOT EXISTS (
SELECT OBJECT_NAME(i.object_id) AS tablename,
i.name AS indexname, 
a.name AS columnname 
FROM sys.indexes i 
INNER JOIN sys.index_columns c 
ON i.object_id = c.object_id AND i.index_id = c.index_id
INNER JOIN sys.all_columns a
ON a.object_id = c.object_id AND a.column_id = c.column_id
WHERE CCU.TABLE_NAME = OBJECT_NAME(i.object_id)
AND CCU.COLUMN_NAME = a.name
)

ORDER BY CCU.TABLE_SCHEMA, CCU.TABLE_NAME, CCU.COLUMN_NAME]]></description>
		<content:encoded><![CDATA[<p>George,</p>
<p>I&#8217;ve a script that does the same but is a little less complicated I think:</p>
<p>SELECT TABLE_NAME, TABLE_SCHEMA, COLUMN_NAME, CONSTRAINT_NAME FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE CCU<br />
INNER JOIN sys.foreign_keys f<br />
ON CCU.TABLE_NAME = object_name(parent_object_id) and CONSTRAINT_NAME = f.name<br />
WHERE f.type = &#8216;F&#8217;<br />
AND NOT EXISTS (<br />
SELECT OBJECT_NAME(i.object_id) AS tablename,<br />
i.name AS indexname,<br />
a.name AS columnname<br />
FROM sys.indexes i<br />
INNER JOIN sys.index_columns c<br />
ON i.object_id = c.object_id AND i.index_id = c.index_id<br />
INNER JOIN sys.all_columns a<br />
ON a.object_id = c.object_id AND a.column_id = c.column_id<br />
WHERE CCU.TABLE_NAME = OBJECT_NAME(i.object_id)<br />
AND CCU.COLUMN_NAME = a.name<br />
)</p>
<p>ORDER BY CCU.TABLE_SCHEMA, CCU.TABLE_NAME, CCU.COLUMN_NAME</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: venkat</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-39355</link>
		<dc:creator><![CDATA[venkat]]></dc:creator>
		<pubDate>Thu, 19 Jun 2008 10:49:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-39355</guid>
		<description><![CDATA[simply superb! gr8 work!]]></description>
		<content:encoded><![CDATA[<p>simply superb! gr8 work!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER - 2005 - Find Tables With Foreign Key Constraint in Database - Part 2 Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-38285</link>
		<dc:creator><![CDATA[SQL SERVER - 2005 - Find Tables With Foreign Key Constraint in Database - Part 2 Journey to SQL Authority with Pinal Dave]]></dc:creator>
		<pubDate>Sat, 17 May 2008 07:45:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-38285</guid>
		<description><![CDATA[[...] Joffery has provided nice script which is modification to previous article of SQL SERVER - 2005 - Find Tables With Foreign Key Constraint in Database. [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Joffery has provided nice script which is modification to previous article of SQL SERVER &#8211; 2005 &#8211; Find Tables With Foreign Key Constraint in Database. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: joffrey</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-38191</link>
		<dc:creator><![CDATA[joffrey]]></dc:creator>
		<pubDate>Fri, 16 May 2008 08:47:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-38191</guid>
		<description><![CDATA[Hi Pinal

Very interesting article and of great help.
I made a little addition to your code. As I wanted also to know what the FKs are doing in the Table (referential integrity on update and on delete) I added two columns to your superb query. And a little bit of ordering :)
Maybe it helps other readers.

SELECT f.name AS ForeignKey,
   OBJECT_NAME(f.parent_object_id) AS TableName,
   COL_NAME(fc.parent_object_id, 
   fc.parent_column_id) AS ColumnName,
   OBJECT_NAME (f.referenced_object_id) AS ReferenceTableName,
   COL_NAME(fc.referenced_object_id, 
   fc.referenced_column_id) AS ReferenceColumnName,
   f.update_referential_action_desc AS UpdateAction,
   f.delete_referential_action_desc AS DeleteAction
FROM sys.foreign_keys AS f
INNER JOIN sys.foreign_key_columns AS fc
   ON f.OBJECT_ID = fc.constraint_object_id
ORDER BY TableName ASC, ColumnName ASC]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal</p>
<p>Very interesting article and of great help.<br />
I made a little addition to your code. As I wanted also to know what the FKs are doing in the Table (referential integrity on update and on delete) I added two columns to your superb query. And a little bit of ordering :)<br />
Maybe it helps other readers.</p>
<p>SELECT f.name AS ForeignKey,<br />
   OBJECT_NAME(f.parent_object_id) AS TableName,<br />
   COL_NAME(fc.parent_object_id,<br />
   fc.parent_column_id) AS ColumnName,<br />
   OBJECT_NAME (f.referenced_object_id) AS ReferenceTableName,<br />
   COL_NAME(fc.referenced_object_id,<br />
   fc.referenced_column_id) AS ReferenceColumnName,<br />
   f.update_referential_action_desc AS UpdateAction,<br />
   f.delete_referential_action_desc AS DeleteAction<br />
FROM sys.foreign_keys AS f<br />
INNER JOIN sys.foreign_key_columns AS fc<br />
   ON f.OBJECT_ID = fc.constraint_object_id<br />
ORDER BY TableName ASC, ColumnName ASC</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TOM</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-38021</link>
		<dc:creator><![CDATA[TOM]]></dc:creator>
		<pubDate>Wed, 14 May 2008 12:12:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-38021</guid>
		<description><![CDATA[Hi Pinal,

Your articles are always great source of information. Can u provide code i mean query to add FK on  new table

Thanks
Tom]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>Your articles are always great source of information. Can u provide code i mean query to add FK on  new table</p>
<p>Thanks<br />
Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sanjoy Banerjee</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-36849</link>
		<dc:creator><![CDATA[sanjoy Banerjee]]></dc:creator>
		<pubDate>Mon, 05 May 2008 14:01:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-36849</guid>
		<description><![CDATA[i want to know the Foreign key name between two tables.]]></description>
		<content:encoded><![CDATA[<p>i want to know the Foreign key name between two tables.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: M Azim</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-35672</link>
		<dc:creator><![CDATA[M Azim]]></dc:creator>
		<pubDate>Sat, 26 Apr 2008 11:31:44 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-35672</guid>
		<description><![CDATA[Hi Pinal,

Your articles are always great source of information.   

Kind Regards,

Azim]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>Your articles are always great source of information.   </p>
<p>Kind Regards,</p>
<p>Azim</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: George Kopf</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-34054</link>
		<dc:creator><![CDATA[George Kopf]]></dc:creator>
		<pubDate>Fri, 29 Feb 2008 01:29:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/#comment-34054</guid>
		<description><![CDATA[I have written a script which I believe will list all the Foreign Key constraints that are missing supporting indexes.  But since I&#039;m very inexperienced with SQL Server I was hoping I could throw this over the fence and let the big dogs chew on it.

Thanks in advance for any and all criticisim.

George


select C.Table_Name,
       C.Constraint_Name,
       C.Constraint_Columns
  from
       (select object_name(i.object_id) table_name,
               i.name index_name, 
               max(case index_column_id when 1 then col_name(ic.object_id,ic.column_id) else &#039;&#039; end)+
               max(case index_column_id when 2 then col_name(ic.object_id,ic.column_id) else &#039;&#039; end)+
               max(case index_column_id when 3 then col_name(ic.object_id,ic.column_id) else &#039;&#039; end)+
               max(case index_column_id when 4 then col_name(ic.object_id,ic.column_id) else &#039;&#039; end)+
               max(case index_column_id when 5 then col_name(ic.object_id,ic.column_id) else &#039;&#039; end)+
               max(case index_column_id when 6 then col_name(ic.object_id,ic.column_id) else &#039;&#039; end)+
               max(case index_column_id when 7 then col_name(ic.object_id,ic.column_id) else &#039;&#039; end)+
               max(case index_column_id when 8 then col_name(ic.object_id,ic.column_id) else &#039;&#039; end)+
               max(case index_column_id when 9 then col_name(ic.object_id,ic.column_id) else &#039;&#039; end)+
               max(case index_column_id when 10 then col_name(ic.object_id,ic.column_id) else &#039;&#039; end) index_columns
          from sys.index_columns ic,
               sys.indexes i
         WHERE ic.index_id = i.index_id
           AND ic.object_id = i.object_id
           AND OBJECTPROPERTY(i.OBJECT_ID,&#039;IsUserTable&#039;) = 1 
           AND i.index_id != 1
        GROUP BY i.object_id, i.name) as I RIGHT OUTER JOIN
       (select kcu.table_name,
               kcu.constraint_name,
               max(case kcu.ordinal_position when 1 then kcu.column_name else &#039;&#039; end)+
               max(case kcu.ordinal_position when 2 then kcu.column_name else &#039;&#039; end)+
               max(case kcu.ordinal_position when 3 then kcu.column_name else &#039;&#039; end)+
               max(case kcu.ordinal_position when 4 then kcu.column_name else &#039;&#039; end)+
               max(case kcu.ordinal_position when 5 then kcu.column_name else &#039;&#039; end)+
               max(case kcu.ordinal_position when 6 then kcu.column_name else &#039;&#039; end)+
               max(case kcu.ordinal_position when 7 then kcu.column_name else &#039;&#039; end)+
               max(case kcu.ordinal_position when 8 then kcu.column_name else &#039;&#039; end)+
               max(case kcu.ordinal_position when 9 then kcu.column_name else &#039;&#039; end)+
               max(case kcu.ordinal_position when 10 then kcu.column_name else &#039;&#039; end) constraint_columns
          from information_schema.key_column_usage kcu,
               information_schema.referential_constraints rc
         where rc.constraint_name = kcu.constraint_name
         group by kcu.table_name, kcu.constraint_name) as C
on C.Table_Name = I.Table_Name
and I.Index_Columns like C.Constraint_Columns + &#039;%&#039;
where I.Table_Name is null]]></description>
		<content:encoded><![CDATA[<p>I have written a script which I believe will list all the Foreign Key constraints that are missing supporting indexes.  But since I&#8217;m very inexperienced with SQL Server I was hoping I could throw this over the fence and let the big dogs chew on it.</p>
<p>Thanks in advance for any and all criticisim.</p>
<p>George</p>
<p>select C.Table_Name,<br />
       C.Constraint_Name,<br />
       C.Constraint_Columns<br />
  from<br />
       (select object_name(i.object_id) table_name,<br />
               i.name index_name,<br />
               max(case index_column_id when 1 then col_name(ic.object_id,ic.column_id) else &#8221; end)+<br />
               max(case index_column_id when 2 then col_name(ic.object_id,ic.column_id) else &#8221; end)+<br />
               max(case index_column_id when 3 then col_name(ic.object_id,ic.column_id) else &#8221; end)+<br />
               max(case index_column_id when 4 then col_name(ic.object_id,ic.column_id) else &#8221; end)+<br />
               max(case index_column_id when 5 then col_name(ic.object_id,ic.column_id) else &#8221; end)+<br />
               max(case index_column_id when 6 then col_name(ic.object_id,ic.column_id) else &#8221; end)+<br />
               max(case index_column_id when 7 then col_name(ic.object_id,ic.column_id) else &#8221; end)+<br />
               max(case index_column_id when 8 then col_name(ic.object_id,ic.column_id) else &#8221; end)+<br />
               max(case index_column_id when 9 then col_name(ic.object_id,ic.column_id) else &#8221; end)+<br />
               max(case index_column_id when 10 then col_name(ic.object_id,ic.column_id) else &#8221; end) index_columns<br />
          from sys.index_columns ic,<br />
               sys.indexes i<br />
         WHERE ic.index_id = i.index_id<br />
           AND ic.object_id = i.object_id<br />
           AND OBJECTPROPERTY(i.OBJECT_ID,&#8217;IsUserTable&#8217;) = 1<br />
           AND i.index_id != 1<br />
        GROUP BY i.object_id, i.name) as I RIGHT OUTER JOIN<br />
       (select kcu.table_name,<br />
               kcu.constraint_name,<br />
               max(case kcu.ordinal_position when 1 then kcu.column_name else &#8221; end)+<br />
               max(case kcu.ordinal_position when 2 then kcu.column_name else &#8221; end)+<br />
               max(case kcu.ordinal_position when 3 then kcu.column_name else &#8221; end)+<br />
               max(case kcu.ordinal_position when 4 then kcu.column_name else &#8221; end)+<br />
               max(case kcu.ordinal_position when 5 then kcu.column_name else &#8221; end)+<br />
               max(case kcu.ordinal_position when 6 then kcu.column_name else &#8221; end)+<br />
               max(case kcu.ordinal_position when 7 then kcu.column_name else &#8221; end)+<br />
               max(case kcu.ordinal_position when 8 then kcu.column_name else &#8221; end)+<br />
               max(case kcu.ordinal_position when 9 then kcu.column_name else &#8221; end)+<br />
               max(case kcu.ordinal_position when 10 then kcu.column_name else &#8221; end) constraint_columns<br />
          from information_schema.key_column_usage kcu,<br />
               information_schema.referential_constraints rc<br />
         where rc.constraint_name = kcu.constraint_name<br />
         group by kcu.table_name, kcu.constraint_name) as C<br />
on C.Table_Name = I.Table_Name<br />
and I.Index_Columns like C.Constraint_Columns + &#8216;%&#8217;<br />
where I.Table_Name is null</p>
]]></content:encoded>
	</item>
</channel>
</rss>

