<?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; List All The Constraint of Database &#8211; Find Primary Key and Foreign Key Constraint in Database</title>
	<atom:link href="http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Thu, 09 Feb 2012 19:36:10 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: SQL SERVER &#8211; Various Ways to Create Constraints &#8211; Quiz &#8211; Puzzle &#8211; 17 of 31 &#171; SQL Server Journey with SQL Authority</title>
		<link>http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-239876</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Various Ways to Create Constraints &#8211; Quiz &#8211; Puzzle &#8211; 17 of 31 &#171; SQL Server Journey with SQL Authority]]></dc:creator>
		<pubDate>Wed, 18 Jan 2012 01:31:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-239876</guid>
		<description><![CDATA[[...] SQL Server Interview Questions and Answers ISBN: 1466405643 Page#137-139 Prevent Constraint to Allow NULL Create Default Constraint Over Table Column Create Primary Key with Specific Name when Creating Table Creating Primary Key, Foreign Key and Default Constraint How to ALTER CONSTRAINT Disable CHECK Constraint – Enable CHECK Constraint Query to Display Foreign Key Relationships and Name of the Constraint for Each Table in Database Lis... [...]]]></description>
		<content:encoded><![CDATA[<p>[...] SQL Server Interview Questions and Answers ISBN: 1466405643 Page#137-139 Prevent Constraint to Allow NULL Create Default Constraint Over Table Column Create Primary Key with Specific Name when Creating Table Creating Primary Key, Foreign Key and Default Constraint How to ALTER CONSTRAINT Disable CHECK Constraint – Enable CHECK Constraint Query to Display Foreign Key Relationships and Name of the Constraint for Each Table in Database Lis&#8230; [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Russell</title>
		<link>http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-211457</link>
		<dc:creator><![CDATA[Eric Russell]]></dc:creator>
		<pubDate>Mon, 05 Dec 2011 16:56:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-211457</guid>
		<description><![CDATA[A common scenario is where one needs write a schema change script to drop a column from a table, but first a constraint that references the column must be dropped. If the constraint has a name that was auto generated (ex: DF__MyTable_MyColumn__26E730D3), then that&#039;s problematic, because the name may be different across dev, qa, prod, etc. So, here is an example for dynamically determining the name of constraint and then dropping it.
 
declare @myconstraint varchar(8000);
select @myconstraint = name 
  from sys.default_constraints 
    where object_name(parent_object_id) = &#039;mytable&#039;
      and col_name (parent_object_id, parent_column_id) = &#039;mycolumn&#039;;
if @myconstraint is not null
  exec(&#039;alter table mytable drop constraint &#039;+@myconstraint);]]></description>
		<content:encoded><![CDATA[<p>A common scenario is where one needs write a schema change script to drop a column from a table, but first a constraint that references the column must be dropped. If the constraint has a name that was auto generated (ex: DF__MyTable_MyColumn__26E730D3), then that&#8217;s problematic, because the name may be different across dev, qa, prod, etc. So, here is an example for dynamically determining the name of constraint and then dropping it.</p>
<p>declare @myconstraint varchar(8000);<br />
select @myconstraint = name<br />
  from sys.default_constraints<br />
    where object_name(parent_object_id) = &#8216;mytable&#8217;<br />
      and col_name (parent_object_id, parent_column_id) = &#8216;mycolumn&#8217;;<br />
if @myconstraint is not null<br />
  exec(&#8216;alter table mytable drop constraint &#8216;+@myconstraint);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raja Jeevan Kumar Maduri</title>
		<link>http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-195989</link>
		<dc:creator><![CDATA[Raja Jeevan Kumar Maduri]]></dc:creator>
		<pubDate>Tue, 15 Nov 2011 11:05:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-195989</guid>
		<description><![CDATA[Folks,

I would want to run a query against a database where in I wanted to specify a column/field, which has been referenced in multiple DB tables. And the result of the query should retrieve me information about the field&#039;s reference in a particular DB table and the column name being referenced along with the field description/documentation, if any. I am not a developer or a DBA. But, I just need this information for documentation. Thanks a ton before hand for responding back to my query.]]></description>
		<content:encoded><![CDATA[<p>Folks,</p>
<p>I would want to run a query against a database where in I wanted to specify a column/field, which has been referenced in multiple DB tables. And the result of the query should retrieve me information about the field&#8217;s reference in a particular DB table and the column name being referenced along with the field description/documentation, if any. I am not a developer or a DBA. But, I just need this information for documentation. Thanks a ton before hand for responding back to my query.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pavana</title>
		<link>http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-188339</link>
		<dc:creator><![CDATA[Pavana]]></dc:creator>
		<pubDate>Fri, 04 Nov 2011 14:35:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-188339</guid>
		<description><![CDATA[Sir, if i ve given name to some constraints such as pk1 etc and at last if i want to know the constraint names that i ve assigned then hw can i see using select statements? Plz reply]]></description>
		<content:encoded><![CDATA[<p>Sir, if i ve given name to some constraints such as pk1 etc and at last if i want to know the constraint names that i ve assigned then hw can i see using select statements? Plz reply</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gustavo</title>
		<link>http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-168170</link>
		<dc:creator><![CDATA[Gustavo]]></dc:creator>
		<pubDate>Thu, 15 Sep 2011 00:39:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-168170</guid>
		<description><![CDATA[Anyone know if there is any way to get the constaintas tha are defined as &quot;with check add&quot;?]]></description>
		<content:encoded><![CDATA[<p>Anyone know if there is any way to get the constaintas tha are defined as &#8220;with check add&#8221;?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bkranthi</title>
		<link>http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-155016</link>
		<dc:creator><![CDATA[bkranthi]]></dc:creator>
		<pubDate>Mon, 08 Aug 2011 12:02:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-155016</guid>
		<description><![CDATA[how to find out not null constraints columns in a table using sql command]]></description>
		<content:encoded><![CDATA[<p>how to find out not null constraints columns in a table using sql command</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Manoj</title>
		<link>http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-147618</link>
		<dc:creator><![CDATA[Manoj]]></dc:creator>
		<pubDate>Tue, 12 Jul 2011 04:48:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-147618</guid>
		<description><![CDATA[I think it will not solve my problem.

The following query returns all related tables for tbl1.

select
o1.name as Referencing_Object_name
, c1.name as referencing_column_Name
, o2.name as Referenced_Object_name
, c2.name as Referenced_Column_Name
, s.name as Constraint_name
from sysforeignkeys fk
inner join sysobjects o1 on fk.fkeyid = o1.id
inner join sysobjects o2 on fk.rkeyid = o2.id
inner join syscolumns c1 on c1.id = o1.id and c1.colid = fk.fkey
inner join syscolumns c2 on c2.id = o2.id and c2.colid = fk.rkey
inner join sysobjects s on fk.constid = s.id
and o2.name=&#039;tbl1&#039; and c2.name=&#039;ID&#039;

I also need to get is there any data in the referenced tables.

We can do this by writing a dynamic query by checking count in each table.

Other than this i am looking for a simplest way.

When we delete a record from the main table, and it has some references,we usually get the below error msg.

The DELETE statement conflicted with the REFERENCE constraint &quot;FK_tbl3_tbl1&quot;. The conflict occurred in database &quot; db1 &quot;, table &quot;dbo.tbl3&quot;, column &#039;ID&#039;.
The statement has been terminated.

So definitely SQL Server should have some system procedures, that is checking this dependencies(means existence of records in related tables).

What is that sp..?

Thanks]]></description>
		<content:encoded><![CDATA[<p>I think it will not solve my problem.</p>
<p>The following query returns all related tables for tbl1.</p>
<p>select<br />
o1.name as Referencing_Object_name<br />
, c1.name as referencing_column_Name<br />
, o2.name as Referenced_Object_name<br />
, c2.name as Referenced_Column_Name<br />
, s.name as Constraint_name<br />
from sysforeignkeys fk<br />
inner join sysobjects o1 on fk.fkeyid = o1.id<br />
inner join sysobjects o2 on fk.rkeyid = o2.id<br />
inner join syscolumns c1 on c1.id = o1.id and c1.colid = fk.fkey<br />
inner join syscolumns c2 on c2.id = o2.id and c2.colid = fk.rkey<br />
inner join sysobjects s on fk.constid = s.id<br />
and o2.name=&#8217;tbl1&#8242; and c2.name=&#8217;ID&#8217;</p>
<p>I also need to get is there any data in the referenced tables.</p>
<p>We can do this by writing a dynamic query by checking count in each table.</p>
<p>Other than this i am looking for a simplest way.</p>
<p>When we delete a record from the main table, and it has some references,we usually get the below error msg.</p>
<p>The DELETE statement conflicted with the REFERENCE constraint &#8220;FK_tbl3_tbl1&#8243;. The conflict occurred in database &#8221; db1 &#8220;, table &#8220;dbo.tbl3&#8243;, column &#8216;ID&#8217;.<br />
The statement has been terminated.</p>
<p>So definitely SQL Server should have some system procedures, that is checking this dependencies(means existence of records in related tables).</p>
<p>What is that sp..?</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-146658</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Thu, 07 Jul 2011 13:36:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-146658</guid>
		<description><![CDATA[Use join or exists

select * from table as t exists(select * from othertable ot where t.id=ot.id)]]></description>
		<content:encoded><![CDATA[<p>Use join or exists</p>
<p>select * from table as t exists(select * from othertable ot where t.id=ot.id)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Manoj</title>
		<link>http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-146375</link>
		<dc:creator><![CDATA[Manoj]]></dc:creator>
		<pubDate>Wed, 06 Jul 2011 11:05:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-146375</guid>
		<description><![CDATA[Hello,

Is there any way to get the data in one table is referencing in any other tables


For eg: I have 3 tables say tbl1,tbl2,tbl3.

tbl1 contains 3 records say 1,2,3

But only 1 and 2 are referencing tbl2 and tbl3,

If we delete the record 1 or 2 from tbl1 ,it is not possible.since the data is using in tbl2 or tbl3.

But if delete 3 from tbl1 it is possible.

So my question is,   the way to find out whether the data is referencing in some other places without writing the delete query.

Through proc I pass the values 1,2,3 etc.


Thanks.
Manoj]]></description>
		<content:encoded><![CDATA[<p>Hello,</p>
<p>Is there any way to get the data in one table is referencing in any other tables</p>
<p>For eg: I have 3 tables say tbl1,tbl2,tbl3.</p>
<p>tbl1 contains 3 records say 1,2,3</p>
<p>But only 1 and 2 are referencing tbl2 and tbl3,</p>
<p>If we delete the record 1 or 2 from tbl1 ,it is not possible.since the data is using in tbl2 or tbl3.</p>
<p>But if delete 3 from tbl1 it is possible.</p>
<p>So my question is,   the way to find out whether the data is referencing in some other places without writing the delete query.</p>
<p>Through proc I pass the values 1,2,3 etc.</p>
<p>Thanks.<br />
Manoj</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-140197</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Fri, 10 Jun 2011 08:32:53 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-140197</guid>
		<description><![CDATA[Look at these views

select * from INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE 
select * from INFORMATION_SCHEMA.CHECK_CONSTRAINTS]]></description>
		<content:encoded><![CDATA[<p>Look at these views</p>
<p>select * from INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE<br />
select * from INFORMATION_SCHEMA.CHECK_CONSTRAINTS</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: el jk</title>
		<link>http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-139847</link>
		<dc:creator><![CDATA[el jk]]></dc:creator>
		<pubDate>Wed, 08 Jun 2011 19:45:51 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-139847</guid>
		<description><![CDATA[does anybody know how to list the column names which are included in the check constraint]]></description>
		<content:encoded><![CDATA[<p>does anybody know how to list the column names which are included in the check constraint</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alderi Pereira</title>
		<link>http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-135254</link>
		<dc:creator><![CDATA[Alderi Pereira]]></dc:creator>
		<pubDate>Thu, 19 May 2011 13:12:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-135254</guid>
		<description><![CDATA[if object_id(&#039;tempdb..#tmp&#039;) is not null 
	drop table #tmp

select
  &#039;[&#039; + SCHEMA_NAME(o1.schema_id) + &#039;].[&#039; + o1.name + &#039;]&#039; as Referencing_Object_name
, s.name as Constraint_name
, c1.name as referencing_column_Name
, &#039;[&#039; + SCHEMA_NAME(o2.schema_id) + &#039;].[&#039; + o2.name + &#039;]&#039; as Referenced_Object_name
, c2.name as Referenced_Column_Name
, fk.keyno as orderKey
, &#039;[&#039; + SCHEMA_NAME(o1.schema_id)   + &#039;].[&#039; + s.name + &#039;]&#039; Constraint_name_schema
into #tmp
from sysforeignkeys fk
inner join sys.objects o1 on fk.fkeyid = o1.object_id
inner join sys.objects o2 on fk.rkeyid = o2.object_id
inner join sys.columns c1 on c1.object_id = o1.object_id and c1.column_id = fk.fkey
inner join sys.columns c2 on c2.object_id = o2.object_id and c2.column_id = fk.rkey
inner join sys.objects s on fk.constid = s.object_id
and o2.name=&#039;&lt;&gt;&#039; -- this predicate for a specific table
order by 1, fk.keyno

select distinct
&#039;IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N&#039;&#039;&#039;+ Constraint_name_schema + &#039;&#039;&#039;) AND parent_object_id = OBJECT_ID(N&#039;&#039;&#039; + Referencing_Object_name  + &#039;&#039;&#039;))&#039; + char(13) + char(10) + char(9) + 
&#039;ALTER TABLE &#039; + 
Referencing_Object_name  + 
&#039; DROP CONSTRAINT &#039; + 
Constraint_name            
from #tmp o1

select distinct
&#039;ALTER TABLE &#039; + 
Referencing_Object_name  + 
&#039; WITH NOCHECK ADD CONSTRAINT &#039; + 
Constraint_name   + 
&#039; FOREIGN KEY &#039; + 
&#039;(&#039; +
STUFF(( SELECT 
                                &#039;],[&#039; + c1.referencing_column_Name 
                        FROM  #tmp c1 
                        where c1.Referencing_Object_name = o1.Referencing_Object_name 
                        group by c1.referencing_column_Name,orderKey
                        order by orderKey
                        FOR XML PATH(&#039;&#039;)
                      ), 1, 2, &#039;&#039;) + &#039;]&#039; 
+ &#039;)&#039; + char(13) + char(10) + char(9) + 
&#039; REFERENCES &#039; +                        
Referenced_Object_name +
&#039;(&#039; +  
STUFF(( SELECT 
                                &#039;],[&#039; + c1.Referenced_Column_Name 
                        FROM  #tmp c1 
                        where c1.Referenced_Object_name = o1.Referenced_Object_name 
                        group by c1.Referenced_Column_Name,orderKey
                        order by orderKey
                        FOR XML PATH(&#039;&#039;)
                      ), 1, 2, &#039;&#039;) + &#039;]&#039;                   
+ &#039;)&#039;                      
from #tmp o1]]></description>
		<content:encoded><![CDATA[<p>if object_id(&#8216;tempdb..#tmp&#8217;) is not null<br />
	drop table #tmp</p>
<p>select<br />
  &#8216;[' + SCHEMA_NAME(o1.schema_id) + '].[' + o1.name + ']&#8216; as Referencing_Object_name<br />
, s.name as Constraint_name<br />
, c1.name as referencing_column_Name<br />
, &#8216;[' + SCHEMA_NAME(o2.schema_id) + '].[' + o2.name + ']&#8216; as Referenced_Object_name<br />
, c2.name as Referenced_Column_Name<br />
, fk.keyno as orderKey<br />
, &#8216;[' + SCHEMA_NAME(o1.schema_id)   + '].[' + s.name + ']&#8216; Constraint_name_schema<br />
into #tmp<br />
from sysforeignkeys fk<br />
inner join sys.objects o1 on fk.fkeyid = o1.object_id<br />
inner join sys.objects o2 on fk.rkeyid = o2.object_id<br />
inner join sys.columns c1 on c1.object_id = o1.object_id and c1.column_id = fk.fkey<br />
inner join sys.columns c2 on c2.object_id = o2.object_id and c2.column_id = fk.rkey<br />
inner join sys.objects s on fk.constid = s.object_id<br />
and o2.name=&#8217;&lt;&gt;&#8217; &#8212; this predicate for a specific table<br />
order by 1, fk.keyno</p>
<p>select distinct<br />
&#8216;IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N&#8221;&#8217;+ Constraint_name_schema + &#8221;&#8217;) AND parent_object_id = OBJECT_ID(N&#8221;&#8217; + Referencing_Object_name  + &#8221;&#8217;))&#8217; + char(13) + char(10) + char(9) +<br />
&#8216;ALTER TABLE &#8216; +<br />
Referencing_Object_name  +<br />
&#8216; DROP CONSTRAINT &#8216; +<br />
Constraint_name<br />
from #tmp o1</p>
<p>select distinct<br />
&#8216;ALTER TABLE &#8216; +<br />
Referencing_Object_name  +<br />
&#8216; WITH NOCHECK ADD CONSTRAINT &#8216; +<br />
Constraint_name   +<br />
&#8216; FOREIGN KEY &#8216; +<br />
&#8216;(&#8216; +<br />
STUFF(( SELECT<br />
                                &#8216;],[' + c1.referencing_column_Name<br />
                        FROM  #tmp c1<br />
                        where c1.Referencing_Object_name = o1.Referencing_Object_name<br />
                        group by c1.referencing_column_Name,orderKey<br />
                        order by orderKey<br />
                        FOR XML PATH('')<br />
                      ), 1, 2, '') + ']&#8216;<br />
+ &#8216;)&#8217; + char(13) + char(10) + char(9) +<br />
&#8216; REFERENCES &#8216; +<br />
Referenced_Object_name +<br />
&#8216;(&#8216; +<br />
STUFF(( SELECT<br />
                                &#8216;],[' + c1.Referenced_Column_Name<br />
                        FROM  #tmp c1<br />
                        where c1.Referenced_Object_name = o1.Referenced_Object_name<br />
                        group by c1.Referenced_Column_Name,orderKey<br />
                        order by orderKey<br />
                        FOR XML PATH('')<br />
                      ), 1, 2, '') + ']&#8216;<br />
+ &#8216;)&#8217;<br />
from #tmp o1</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anand M</title>
		<link>http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-132486</link>
		<dc:creator><![CDATA[Anand M]]></dc:creator>
		<pubDate>Mon, 02 May 2011 10:12:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-132486</guid>
		<description><![CDATA[would u ple send me  sql  information]]></description>
		<content:encoded><![CDATA[<p>would u ple send me  sql  information</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anand M</title>
		<link>http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-132485</link>
		<dc:creator><![CDATA[Anand M]]></dc:creator>
		<pubDate>Mon, 02 May 2011 10:11:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-132485</guid>
		<description><![CDATA[hello  sir  i need  ur help ...]]></description>
		<content:encoded><![CDATA[<p>hello  sir  i need  ur help &#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ujwala</title>
		<link>http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-132483</link>
		<dc:creator><![CDATA[Ujwala]]></dc:creator>
		<pubDate>Mon, 02 May 2011 09:42:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-132483</guid>
		<description><![CDATA[Sir,
The query of Default Constraint which u have given,i executed that but at d time of inserting d records in d table d is error has occured.
The default value which is hav to go automatically in the table that has not done.
Plz send me d feedback that how to do that.
Thanks.]]></description>
		<content:encoded><![CDATA[<p>Sir,<br />
The query of Default Constraint which u have given,i executed that but at d time of inserting d records in d table d is error has occured.<br />
The default value which is hav to go automatically in the table that has not done.<br />
Plz send me d feedback that how to do that.<br />
Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Satish</title>
		<link>http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-131442</link>
		<dc:creator><![CDATA[Satish]]></dc:creator>
		<pubDate>Wed, 27 Apr 2011 10:00:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-131442</guid>
		<description><![CDATA[Itz good.....]]></description>
		<content:encoded><![CDATA[<p>Itz good&#8230;..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-126770</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Tue, 05 Apr 2011 15:07:37 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-126770</guid>
		<description><![CDATA[You need to parse the error_message() and get that between contraint and cannot]]></description>
		<content:encoded><![CDATA[<p>You need to parse the error_message() and get that between contraint and cannot</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vishwas Khanal</title>
		<link>http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-126718</link>
		<dc:creator><![CDATA[Vishwas Khanal]]></dc:creator>
		<pubDate>Tue, 05 Apr 2011 11:10:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-126718</guid>
		<description><![CDATA[madhivanan,

ERROR_NUMBER()	 -  catches error no,
ERROR_MESSAGE()	 -  catches error msg,
ERROR_PROCEDURE() - catches procedure name ,
ERROR_LINE() - catches line no

How do i catch the constraint name if the error is about the violation of primary key?]]></description>
		<content:encoded><![CDATA[<p>madhivanan,</p>
<p>ERROR_NUMBER()	 &#8211;  catches error no,<br />
ERROR_MESSAGE()	 &#8211;  catches error msg,<br />
ERROR_PROCEDURE() &#8211; catches procedure name ,<br />
ERROR_LINE() &#8211; catches line no</p>
<p>How do i catch the constraint name if the error is about the violation of primary key?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-125923</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Fri, 01 Apr 2011 06:33:27 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-125923</guid>
		<description><![CDATA[exec sp_pkeys xyz]]></description>
		<content:encoded><![CDATA[<p>exec sp_pkeys xyz</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-125889</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Fri, 01 Apr 2011 05:22:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-125889</guid>
		<description><![CDATA[Read about it in SQL Server help file]]></description>
		<content:encoded><![CDATA[<p>Read about it in SQL Server help file</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rajendher</title>
		<link>http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-125886</link>
		<dc:creator><![CDATA[rajendher]]></dc:creator>
		<pubDate>Fri, 01 Apr 2011 04:52:13 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-125886</guid>
		<description><![CDATA[hi sir, 
       explain about constraints and uses of constraints]]></description>
		<content:encoded><![CDATA[<p>hi sir,<br />
       explain about constraints and uses of constraints</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vishwas Khanal</title>
		<link>http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-124965</link>
		<dc:creator><![CDATA[Vishwas Khanal]]></dc:creator>
		<pubDate>Fri, 25 Mar 2011 06:52:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-124965</guid>
		<description><![CDATA[Does any one have an idea about how to get the violated constrained name.

eg If I get an error Violation of PRIMARY KEY constraint &#039;pk24&#039;. Cannot insert duplicate key in object &#039;xyz&#039;.
I would like to catch pk24 alone.

Is there a way out?]]></description>
		<content:encoded><![CDATA[<p>Does any one have an idea about how to get the violated constrained name.</p>
<p>eg If I get an error Violation of PRIMARY KEY constraint &#8216;pk24&#8242;. Cannot insert duplicate key in object &#8216;xyz&#8217;.<br />
I would like to catch pk24 alone.</p>
<p>Is there a way out?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: P V Nidheesh</title>
		<link>http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-118815</link>
		<dc:creator><![CDATA[P V Nidheesh]]></dc:creator>
		<pubDate>Wed, 16 Feb 2011 11:54:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-118815</guid>
		<description><![CDATA[While I was working in SQL server 2005, I used to know domain constraint have higher priority than referential constraint. Now I am little bit confusion regarding the priority among constraints in sql server. I will be thankful if u give a brief discussion regarding priority among constraints.]]></description>
		<content:encoded><![CDATA[<p>While I was working in SQL server 2005, I used to know domain constraint have higher priority than referential constraint. Now I am little bit confusion regarding the priority among constraints in sql server. I will be thankful if u give a brief discussion regarding priority among constraints.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raj</title>
		<link>http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-100292</link>
		<dc:creator><![CDATA[Raj]]></dc:creator>
		<pubDate>Tue, 16 Nov 2010 07:47:56 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-100292</guid>
		<description><![CDATA[@abhay
Really helpfull....Thanks]]></description>
		<content:encoded><![CDATA[<p>@abhay<br />
Really helpfull&#8230;.Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: مجتبی ولی</title>
		<link>http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-85311</link>
		<dc:creator><![CDATA[مجتبی ولی]]></dc:creator>
		<pubDate>Thu, 26 Aug 2010 07:52:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/#comment-85311</guid>
		<description><![CDATA[I think it is better when we change the condition

SELECT *, OBJECT_NAME(OBJECT_ID) AS ConstraintName,SCHEMA_NAME(schema_id) AS SchemaName,OBJECT_NAME(parent_object_id) AS TableName,type_desc AS ConstraintType FROM sys.objects WHERE (OBJECTPROPERTY(object_Id, N&#039;IsConstraint&#039;) = 1)

i don&#039;t know if we gain a performance boost or not but it looks more reliable to me]]></description>
		<content:encoded><![CDATA[<p>I think it is better when we change the condition</p>
<p>SELECT *, OBJECT_NAME(OBJECT_ID) AS ConstraintName,SCHEMA_NAME(schema_id) AS SchemaName,OBJECT_NAME(parent_object_id) AS TableName,type_desc AS ConstraintType FROM sys.objects WHERE (OBJECTPROPERTY(object_Id, N&#8217;IsConstraint&#8217;) = 1)</p>
<p>i don&#8217;t know if we gain a performance boost or not but it looks more reliable to me</p>
]]></content:encoded>
	</item>
</channel>
</rss>

