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 |
|
adityav22
Starting Member
1 Post |
Posted - 2007-02-22 : 15:07:03
|
| Is there a query that can return teh name of the primary key column of a table ? |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-02-22 : 15:23:36
|
| SELECT COLUMN_NAMEFROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS tcINNER JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccuON tc.CONSTRAINT_NAME = ccu.CONSTRAINT_NAMEWHERE tc.TABLE_NAME = 'TableNameGoesHere' AND tc.CONSTRAINT_TYPE = 'PRIMARY KEY'Tara Kizer |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2007-02-22 : 17:36:15
|
| [code]exec sp_helpindex MyTableName[/code]CODO ERGO SUM |
 |
|
|
|
|
|