Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 stored procedure

Author  Topic 

mahesh_bote
Constraint Violating Yak Guru

298 Posts

Posted - 2006-08-21 : 05:46:56
need one stored procedure.

Using one procedure i want to know the columns that are associated with the primary key and the name of the primary key.


The output should be as follows


Table Name PK_Constraint Name Columns

TABLE017 PK_TABLE009 COLUMN001

TABLE017 FK_TABLE009 COLUMN002


Mahesh

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-08-21 : 05:58:48
[code]select kcu.Table_Name, kcu.Constraint_Name, kcu.Column_Name from information_schema.table_constraints tc join information_schema.key_column_usage kcu
on tc.Constraint_Name = kcu.Constraint_Name and tc.Constraint_Type = 'PRIMARY KEY'
[/code]

Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

mahesh_bote
Constraint Violating Yak Guru

298 Posts

Posted - 2006-08-21 : 06:08:47
Thank You very much Harsh

Mahesh
Go to Top of Page
   

- Advertisement -