<?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 Primary Key Constraint in Database</title>
	<atom:link href="http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-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-primary-key-constraint-in-database/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Fri, 17 May 2013 15:26:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: S.K.C</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-444009</link>
		<dc:creator><![CDATA[S.K.C]]></dc:creator>
		<pubDate>Mon, 25 Mar 2013 09:24:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-444009</guid>
		<description><![CDATA[Thanks for the post.

It is easy to find the primary keys columns in all tables in a database.]]></description>
		<content:encoded><![CDATA[<p>Thanks for the post.</p>
<p>It is easy to find the primary keys columns in all tables in a database.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hany.helmy</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-432700</link>
		<dc:creator><![CDATA[hany.helmy]]></dc:creator>
		<pubDate>Wed, 06 Mar 2013 08:09:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-432700</guid>
		<description><![CDATA[Thank you all for the useful info, but I have a concern: 

can we get the list of primary key columns in 1 row. for example if we have a composite primary key consists of 4 columns, the above query will retrive all 4 of them in 4 rows, 

question: could it be in 1 row.

thanx.]]></description>
		<content:encoded><![CDATA[<p>Thank you all for the useful info, but I have a concern: </p>
<p>can we get the list of primary key columns in 1 row. for example if we have a composite primary key consists of 4 columns, the above query will retrive all 4 of them in 4 rows, </p>
<p>question: could it be in 1 row.</p>
<p>thanx.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rakesh7044@gmail.com</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-314525</link>
		<dc:creator><![CDATA[rakesh7044@gmail.com]]></dc:creator>
		<pubDate>Tue, 17 Jul 2012 11:22:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-314525</guid>
		<description><![CDATA[SELECT IT.TABLE_NAME ,ITC.CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLES it join INFORMATION_SCHEMA.TABLE_CONSTRAINTS itc ON IT.TABLE_NAME=ITC.TABLE_NAME
WHERE OBJECTPROPERTY(OBJECT_ID(IT.TABLE_NAME),’TableHasPrimaryKey’)=1 AND TABLE_TYPE=’BASE TABLE’ and itc.CONSTRAINT_TYPE=’primary key’]]></description>
		<content:encoded><![CDATA[<p>SELECT IT.TABLE_NAME ,ITC.CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLES it join INFORMATION_SCHEMA.TABLE_CONSTRAINTS itc ON IT.TABLE_NAME=ITC.TABLE_NAME<br />
WHERE OBJECTPROPERTY(OBJECT_ID(IT.TABLE_NAME),’TableHasPrimaryKey’)=1 AND TABLE_TYPE=’BASE TABLE’ and itc.CONSTRAINT_TYPE=’primary key’</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rakesh</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-314524</link>
		<dc:creator><![CDATA[rakesh]]></dc:creator>
		<pubDate>Tue, 17 Jul 2012 11:17:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-314524</guid>
		<description><![CDATA[HI PINAL ,

WE CAN ALSO WRITE IN  OTHER WAY FOR FINDING THE PRIMARY CONSTRAINT NAMES ...



SELECT IT.TABLE_NAME ,ITC.CONSTRAINT_NAME  FROM INFORMATION_SCHEMA.TABLES it  join INFORMATION_SCHEMA.TABLE_CONSTRAINTS itc ON IT.TABLE_NAME=ITC.TABLE_NAME
 WHERE  OBJECTPROPERTY(OBJECT_ID(IT.TABLE_NAME),&#039;TableHasPrimaryKey&#039;)=1 AND TABLE_TYPE=&#039;BASE TABLE&#039; and itc.CONSTRAINT_TYPE=&#039;primary key&#039;]]></description>
		<content:encoded><![CDATA[<p>HI PINAL ,</p>
<p>WE CAN ALSO WRITE IN  OTHER WAY FOR FINDING THE PRIMARY CONSTRAINT NAMES &#8230;</p>
<p>SELECT IT.TABLE_NAME ,ITC.CONSTRAINT_NAME  FROM INFORMATION_SCHEMA.TABLES it  join INFORMATION_SCHEMA.TABLE_CONSTRAINTS itc ON IT.TABLE_NAME=ITC.TABLE_NAME<br />
 WHERE  OBJECTPROPERTY(OBJECT_ID(IT.TABLE_NAME),&#8217;TableHasPrimaryKey&#8217;)=1 AND TABLE_TYPE=&#8217;BASE TABLE&#8217; and itc.CONSTRAINT_TYPE=&#8217;primary key&#8217;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vijay Anand Madhuranaygam</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-236016</link>
		<dc:creator><![CDATA[Vijay Anand Madhuranaygam]]></dc:creator>
		<pubDate>Thu, 12 Jan 2012 12:31:44 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-236016</guid>
		<description><![CDATA[Shall we use this Query?

select [name] from SYS.TABLES where [name] not in (
select distinct(TABLE_NAME) from INFORMATION_SCHEMA.TABLE_CONSTRAINTS) 

The above query will return all the heap tables.

Thanks &amp; regards,
Vijay]]></description>
		<content:encoded><![CDATA[<p>Shall we use this Query?</p>
<p>select [name] from SYS.TABLES where [name] not in (<br />
select distinct(TABLE_NAME) from INFORMATION_SCHEMA.TABLE_CONSTRAINTS) </p>
<p>The above query will return all the heap tables.</p>
<p>Thanks &amp; regards,<br />
Vijay</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Manish</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-132525</link>
		<dc:creator><![CDATA[Manish]]></dc:creator>
		<pubDate>Mon, 02 May 2011 15:46:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-132525</guid>
		<description><![CDATA[Pinal,


You are absolutely the best SQL server authority.]]></description>
		<content:encoded><![CDATA[<p>Pinal,</p>
<p>You are absolutely the best SQL server authority.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fawad Ali</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-130634</link>
		<dc:creator><![CDATA[Fawad Ali]]></dc:creator>
		<pubDate>Sat, 23 Apr 2011 05:48:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-130634</guid>
		<description><![CDATA[hello,

i am trying to write a function in MS SQL which i will pass table_name and PK value and the function will return me the table(s) where that specified PK of the table is used.

like we have two tables;
item                                              purchase
itemID (PK)                                     itemID (FK)
100                                               100

the function will return table name purchase if the (itemID=100) is used in it
 
thanks,]]></description>
		<content:encoded><![CDATA[<p>hello,</p>
<p>i am trying to write a function in MS SQL which i will pass table_name and PK value and the function will return me the table(s) where that specified PK of the table is used.</p>
<p>like we have two tables;<br />
item                                              purchase<br />
itemID (PK)                                     itemID (FK)<br />
100                                               100</p>
<p>the function will return table name purchase if the (itemID=100) is used in it</p>
<p>thanks,</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fawad Ali</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-130628</link>
		<dc:creator><![CDATA[Fawad Ali]]></dc:creator>
		<pubDate>Sat, 23 Apr 2011 05:14:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-130628</guid>
		<description><![CDATA[hi,
i want to write a function in SQL. i will pass table name and value of the pk. on basis of these two parameter i would like to get the name of the table(s) that contains the specified PK as FK. 

thanks.]]></description>
		<content:encoded><![CDATA[<p>hi,<br />
i want to write a function in SQL. i will pass table name and value of the pk. on basis of these two parameter i would like to get the name of the table(s) that contains the specified PK as FK. </p>
<p>thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kumar</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-102394</link>
		<dc:creator><![CDATA[kumar]]></dc:creator>
		<pubDate>Sat, 27 Nov 2010 03:03:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-102394</guid>
		<description><![CDATA[Hi,

I was working on a script that will let me know the order in which  I can insert data in to the tables , so that they do not encounter the referential integrity problem. But I have a table that has got both the primary key and foreign key on the same column and as a result my script show the order of insertion for this table to be 3 , where as when I check it with the help of view dependencies in the management studio its order is 4. any suggestion are appreciated.\
--- Script----------
DECLARE @Iteration int
SET @Iteration = 1
 
Select Table_Name,NULL AS InsertOrderRank into #Table
from Information_Schema.Tables Where Table_Type = &#039;BASE TABLE&#039;
 
Select FK.Constraint_Name as FKConstraintName,
FK.Table_Name as TableName,
CUF.Column_Name as ColumnName,
PK.Table_Name as ReferringTableName,
CUP.Column_Name as ReferringTableColumnName
into #FKColumns
from Information_Schema.REFERENTIAL_CONSTRAINTS RC-- Foreignkeys
JOIN Information_Schema.TABLE_CONSTRAINTS FK
ON RC.Constraint_Name = FK.Constraint_Name
JOIN Information_Schema.TABLE_CONSTRAINTS PK
ON RC.Unique_Constraint_Name = PK.Constraint_Name
JOIN  INFORMATION_SCHEMA.KEY_COLUMN_USAGE CUF
ON FK.Constraint_Name = CUF.Constraint_Name
JOIN  INFORMATION_SCHEMA.KEY_COLUMN_USAGE CUP
ON PK.Constraint_Name = CUP.Constraint_Name
 
update T
Set InsertOrderRank = 1
From #Table T
LEFT JOIN #FKColumns F
on T.Table_Name = F.TableName
WHERE F.TableName IS NULL
 
 
WHILE ((Select Count(1) from #Table where InsertOrderRank IS NULL) &gt; 0)
BEGIN
 
UPDATE T1
Set InsertOrderRank = @Iteration + 1
FROM #Table T1
JOIN
(SELECT Distinct T.Table_Name
From #Table T
INNER JOIN #FKColumns F
on T.Table_Name = F.TableName
INNER JOIN #Table T2
on T2.Table_Name = F.ReferringTableName
Group By T.Table_Name
Having Count(Distinct ISNULL(T2.InsertOrderRank,0)) = @Iteration) as T2
on T1.Table_Name = T2.Table_Name
 
SET @ITeration = @Iteration + 1
 
END
 
Select * from #Table
Order By InsertOrderRank


Thanks]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I was working on a script that will let me know the order in which  I can insert data in to the tables , so that they do not encounter the referential integrity problem. But I have a table that has got both the primary key and foreign key on the same column and as a result my script show the order of insertion for this table to be 3 , where as when I check it with the help of view dependencies in the management studio its order is 4. any suggestion are appreciated.\<br />
&#8212; Script&#8212;&#8212;&#8212;-<br />
DECLARE @Iteration int<br />
SET @Iteration = 1</p>
<p>Select Table_Name,NULL AS InsertOrderRank into #Table<br />
from Information_Schema.Tables Where Table_Type = &#8216;BASE TABLE&#8217;</p>
<p>Select FK.Constraint_Name as FKConstraintName,<br />
FK.Table_Name as TableName,<br />
CUF.Column_Name as ColumnName,<br />
PK.Table_Name as ReferringTableName,<br />
CUP.Column_Name as ReferringTableColumnName<br />
into #FKColumns<br />
from Information_Schema.REFERENTIAL_CONSTRAINTS RC&#8211; Foreignkeys<br />
JOIN Information_Schema.TABLE_CONSTRAINTS FK<br />
ON RC.Constraint_Name = FK.Constraint_Name<br />
JOIN Information_Schema.TABLE_CONSTRAINTS PK<br />
ON RC.Unique_Constraint_Name = PK.Constraint_Name<br />
JOIN  INFORMATION_SCHEMA.KEY_COLUMN_USAGE CUF<br />
ON FK.Constraint_Name = CUF.Constraint_Name<br />
JOIN  INFORMATION_SCHEMA.KEY_COLUMN_USAGE CUP<br />
ON PK.Constraint_Name = CUP.Constraint_Name</p>
<p>update T<br />
Set InsertOrderRank = 1<br />
From #Table T<br />
LEFT JOIN #FKColumns F<br />
on T.Table_Name = F.TableName<br />
WHERE F.TableName IS NULL</p>
<p>WHILE ((Select Count(1) from #Table where InsertOrderRank IS NULL) &gt; 0)<br />
BEGIN</p>
<p>UPDATE T1<br />
Set InsertOrderRank = @Iteration + 1<br />
FROM #Table T1<br />
JOIN<br />
(SELECT Distinct T.Table_Name<br />
From #Table T<br />
INNER JOIN #FKColumns F<br />
on T.Table_Name = F.TableName<br />
INNER JOIN #Table T2<br />
on T2.Table_Name = F.ReferringTableName<br />
Group By T.Table_Name<br />
Having Count(Distinct ISNULL(T2.InsertOrderRank,0)) = @Iteration) as T2<br />
on T1.Table_Name = T2.Table_Name</p>
<p>SET @ITeration = @Iteration + 1</p>
<p>END</p>
<p>Select * from #Table<br />
Order By InsertOrderRank</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phani</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-93305</link>
		<dc:creator><![CDATA[Phani]]></dc:creator>
		<pubDate>Fri, 15 Oct 2010 19:49:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-93305</guid>
		<description><![CDATA[For sec I thought I should call you god. But I think praying god to give you long life and everything you want in life is more appropriate :-) you are simply awesome buddy!!]]></description>
		<content:encoded><![CDATA[<p>For sec I thought I should call you god. But I think praying god to give you long life and everything you want in life is more appropriate :-) you are simply awesome buddy!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Senthilkumar R</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-93273</link>
		<dc:creator><![CDATA[Senthilkumar R]]></dc:creator>
		<pubDate>Fri, 15 Oct 2010 16:31:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-93273</guid>
		<description><![CDATA[Hemadri

Right click on the specified table choose design option. Right click on the column to which you need to create primary key. You will find set primary key option. Just select that.]]></description>
		<content:encoded><![CDATA[<p>Hemadri</p>
<p>Right click on the specified table choose design option. Right click on the column to which you need to create primary key. You will find set primary key option. Just select that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hemadri raju</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-86039</link>
		<dc:creator><![CDATA[hemadri raju]]></dc:creator>
		<pubDate>Wed, 01 Sep 2010 07:25:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-86039</guid>
		<description><![CDATA[how to insert primary key after table is created]]></description>
		<content:encoded><![CDATA[<p>how to insert primary key after table is created</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dily Das</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-82380</link>
		<dc:creator><![CDATA[Dily Das]]></dc:creator>
		<pubDate>Fri, 30 Jul 2010 18:15:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-82380</guid>
		<description><![CDATA[I want to know how to find the primary key for a specific given table.]]></description>
		<content:encoded><![CDATA[<p>I want to know how to find the primary key for a specific given table.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nimrod</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-76463</link>
		<dc:creator><![CDATA[Nimrod]]></dc:creator>
		<pubDate>Wed, 16 Jun 2010 07:03:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-76463</guid>
		<description><![CDATA[ALTER TABLE TABLE_NAME
ADD CONSTRAINT CONSTRAINT_NAME PRIMARY KEY (COLUMN_NAME_1, [COLUMN_NAME_2], [COLUMN_NAME_n])

where n is the nth number, as a Primary Key can have more than one Column]]></description>
		<content:encoded><![CDATA[<p>ALTER TABLE TABLE_NAME<br />
ADD CONSTRAINT CONSTRAINT_NAME PRIMARY KEY (COLUMN_NAME_1, [COLUMN_NAME_2], [COLUMN_NAME_n])</p>
<p>where n is the nth number, as a Primary Key can have more than one Column</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nimrod</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-76462</link>
		<dc:creator><![CDATA[Nimrod]]></dc:creator>
		<pubDate>Wed, 16 Jun 2010 07:02:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-76462</guid>
		<description><![CDATA[ALTER TABLE 
ADD CONSTRAINT  PRIMARY KEY (COLUMN_NAME_1, [COLUMN_NAME_2], [COLUMN_NAME_n])

where n is the nth number, as a Primary Key can have more than one Column]]></description>
		<content:encoded><![CDATA[<p>ALTER TABLE<br />
ADD CONSTRAINT  PRIMARY KEY (COLUMN_NAME_1, [COLUMN_NAME_2], [COLUMN_NAME_n])</p>
<p>where n is the nth number, as a Primary Key can have more than one Column</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: KENSAi</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-70181</link>
		<dc:creator><![CDATA[KENSAi]]></dc:creator>
		<pubDate>Mon, 10 May 2010 21:21:27 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-70181</guid>
		<description><![CDATA[Hi Kash,

you can delete child table records first then parent table through constraint on delete cascade constraints.

You can set this constraints at the same time while creating relationship between two tables.

Thanks
KENSAi]]></description>
		<content:encoded><![CDATA[<p>Hi Kash,</p>
<p>you can delete child table records first then parent table through constraint on delete cascade constraints.</p>
<p>You can set this constraints at the same time while creating relationship between two tables.</p>
<p>Thanks<br />
KENSAi</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Tkatch</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-68071</link>
		<dc:creator><![CDATA[Brian Tkatch]]></dc:creator>
		<pubDate>Fri, 30 Apr 2010 14:07:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-68071</guid>
		<description><![CDATA[@Azadeh

Please post some SQL.

IIUC, you need to ADD a UNIQUE CONSTRAINT to Table B on the PK and FK.]]></description>
		<content:encoded><![CDATA[<p>@Azadeh</p>
<p>Please post some SQL.</p>
<p>IIUC, you need to ADD a UNIQUE CONSTRAINT to Table B on the PK and FK.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Azadeh</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-68054</link>
		<dc:creator><![CDATA[Azadeh]]></dc:creator>
		<pubDate>Fri, 30 Apr 2010 13:11:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-68054</guid>
		<description><![CDATA[I have two tables one of them(table A) has 2 Primary keys (Composite keys) and another one (Table B) has own primary key and a Foreign key which is one of the existing primary key of the Table A.

I am going to make a relation between table A and Table B in this relation Table A is my Primary key Table and Table B is my Foreign key table,and in Foreign key table i select one primary key of Table A which should be set as a primary key field in Table A as Primary key table. when i want to make this relation i get this Error : &#039; The column in the table don&#039;t match an Existing primary key or UNIQUE constraint.


Help me please]]></description>
		<content:encoded><![CDATA[<p>I have two tables one of them(table A) has 2 Primary keys (Composite keys) and another one (Table B) has own primary key and a Foreign key which is one of the existing primary key of the Table A.</p>
<p>I am going to make a relation between table A and Table B in this relation Table A is my Primary key Table and Table B is my Foreign key table,and in Foreign key table i select one primary key of Table A which should be set as a primary key field in Table A as Primary key table. when i want to make this relation i get this Error : &#8216; The column in the table don&#8217;t match an Existing primary key or UNIQUE constraint.</p>
<p>Help me please</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-61545</link>
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
		<pubDate>Sun, 21 Feb 2010 16:48:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-61545</guid>
		<description><![CDATA[Hi Prasad,

To get the list of all indexes of a table use the below query:

SELECT ind.* 
FROM sys.indexes ind INNER JOIN sys.tables tbl 
ON ind.object_id = tbl.object_id
WHERE tbl.name = &#039;yourTableName&#039;

To get the list of all index in a database use the sys.indexes table.

Regards,
Pinal Dave]]></description>
		<content:encoded><![CDATA[<p>Hi Prasad,</p>
<p>To get the list of all indexes of a table use the below query:</p>
<p>SELECT ind.*<br />
FROM sys.indexes ind INNER JOIN sys.tables tbl<br />
ON ind.object_id = tbl.object_id<br />
WHERE tbl.name = &#8216;yourTableName&#8217;</p>
<p>To get the list of all index in a database use the sys.indexes table.</p>
<p>Regards,<br />
Pinal Dave</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: prasad</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-61523</link>
		<dc:creator><![CDATA[prasad]]></dc:creator>
		<pubDate>Sat, 20 Feb 2010 07:38:13 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-61523</guid>
		<description><![CDATA[Hi Pinal,
                     I have one Query,
How to List out of all indexes in particular table and database ??]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,<br />
                     I have one Query,<br />
How to List out of all indexes in particular table and database ??</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kash</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-43721</link>
		<dc:creator><![CDATA[Kash]]></dc:creator>
		<pubDate>Wed, 15 Oct 2008 19:58:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-43721</guid>
		<description><![CDATA[I have one parent table and has 10 child tables.

I would like to delete the child table records first then perent
database level, through constraints and triggers.

All these tables has forign key constrains.

Please advise the better way. I am using sql server 2005.]]></description>
		<content:encoded><![CDATA[<p>I have one parent table and has 10 child tables.</p>
<p>I would like to delete the child table records first then perent<br />
database level, through constraints and triggers.</p>
<p>All these tables has forign key constrains.</p>
<p>Please advise the better way. I am using sql server 2005.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pinaldave</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-43011</link>
		<dc:creator><![CDATA[pinaldave]]></dc:creator>
		<pubDate>Sat, 20 Sep 2008 01:15:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-43011</guid>
		<description><![CDATA[Imran,

You are correct.

Regards,
Pinal Dave ( http://www.SQLAuthority.com )]]></description>
		<content:encoded><![CDATA[<p>Imran,</p>
<p>You are correct.</p>
<p>Regards,<br />
Pinal Dave ( <a href="http://www.SQLAuthority.com" rel="nofollow">http://www.SQLAuthority.com</a> )</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Imran Mohammed</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-43010</link>
		<dc:creator><![CDATA[Imran Mohammed]]></dc:creator>
		<pubDate>Sat, 20 Sep 2008 01:09:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-43010</guid>
		<description><![CDATA[Hello Shwetang,

What I read on internet, is it is not possible to create a foriegn key constraint referencing table outside database. 

I tried myself creating this but had no luck...

The only solution to your problem is triggers. 

or create child table in the same database as parent table.

Thanks,
Imran]]></description>
		<content:encoded><![CDATA[<p>Hello Shwetang,</p>
<p>What I read on internet, is it is not possible to create a foriegn key constraint referencing table outside database. </p>
<p>I tried myself creating this but had no luck&#8230;</p>
<p>The only solution to your problem is triggers. </p>
<p>or create child table in the same database as parent table.</p>
<p>Thanks,<br />
Imran</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shwetang</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-43001</link>
		<dc:creator><![CDATA[Shwetang]]></dc:creator>
		<pubDate>Fri, 19 Sep 2008 18:33:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-43001</guid>
		<description><![CDATA[I&#039;m havin two database, could i map a foeign key constraint in the other database
e.g 
database A-&gt;table xyz.id set primary key
I&#039;wanna make foreign key to
database B-&gt; table xyz.pid

is it possible]]></description>
		<content:encoded><![CDATA[<p>I&#8217;m havin two database, could i map a foeign key constraint in the other database<br />
e.g<br />
database A-&gt;table xyz.id set primary key<br />
I&#8217;wanna make foreign key to<br />
database B-&gt; table xyz.pid</p>
<p>is it possible</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Amit Habu</title>
		<link>http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-40684</link>
		<dc:creator><![CDATA[Amit Habu]]></dc:creator>
		<pubDate>Wed, 23 Jul 2008 08:24:53 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/#comment-40684</guid>
		<description><![CDATA[I want to know how to write a constraint i.e a primary key in already defined table.Alter syntax with constraints]]></description>
		<content:encoded><![CDATA[<p>I want to know how to write a constraint i.e a primary key in already defined table.Alter syntax with constraints</p>
]]></content:encoded>
	</item>
</channel>
</rss>
