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.
| Author |
Topic |
|
Peace2007
Posting Yak Master
239 Posts |
Posted - 2008-08-25 : 01:41:51
|
| Hi, I need to find primary key(s)of a table through T-SQL statements. Could you tell me which system functions I shall use? |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-08-25 : 01:47:32
|
sp_helpindex KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-25 : 02:25:51
|
| [code]SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS c INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE cuON cu.CONSTRAINT_NAME=c.CONSTRAINT_NAMEWHERE c.TABLE_NAME='YourTableNameHere'AND c.CONSTRAINT_TYPE='PRIMARY KEY'[/code] |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-08-25 : 02:43:00
|
| orEXEC sp_pkeys 'table name'MadhivananFailing to plan is Planning to fail |
 |
|
|
Peace2007
Posting Yak Master
239 Posts |
Posted - 2008-08-25 : 02:45:43
|
| Thanks all :) |
 |
|
|
|
|
|