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 |
|
asm
Posting Yak Master
140 Posts |
Posted - 2010-12-24 : 23:01:27
|
| Hi,How do we get the primary key column name and table name from a selected database through query.thanks |
|
|
kumarsudu
Starting Member
1 Post |
Posted - 2010-12-25 : 06:58:10
|
| Hi, SELECT i.name AS IndexName,OBJECT_NAME(ic.OBJECT_ID) AS TableName,COL_NAME(ic.OBJECT_ID,ic.column_id) AS ColumnNameFROM sys.indexes AS iINNER JOIN sys.index_columns AS icON i.OBJECT_ID = ic.OBJECT_IDAND i.index_id = ic.index_idWHERE i.is_primary_key = 1Source:http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/Hope this may help youthanks and regards,kumar |
 |
|
|
|
|
|