Saturday, October 04, 2008

Columns in a Primary Key Index

Query to get the columns in a primary key for a table

select object_name( tableName, indexName,
from sysindexes SI
inner join sysindexkeys SIK
on =
and SIK.indid = SI.indid
inner join syscolumns SC
on SC.colid = SIK.colid
and =
where 1=1
and object_name( = 'SalesHeader'
and SI.status in ( 2066 , 2048 )

No comments: