This is what i did to get a list of primary keys and the column names.
SELECT o.name as
, i.name AS [Index], c.name AS [Column], k.keyno as [Keyno]
FROM sysindexkeys k INNER JOIN
syscolumns c ON k.id = c.id AND
k.colid = c.colid INNER JOIN
sysindexes i ON k.id = i.id AND
k.indid = i.indid INNER JOIN
sysobjects o ON c.id = o.id INNER JOIN
sysobjects p on p.parent_obj = o.id AND
p.name = i.name
WHERE o.type = 'U' and p.xtype = 'PK' and o.name
<> 'dtproperties'
ORDER BY o.name, i.name, k.keyno
There may be a cleaner way, would welcome comments.
Cheers.
SELECT o.name as
FROM sysindexkeys k INNER JOIN
syscolumns c ON k.id = c.id AND
k.colid = c.colid INNER JOIN
sysindexes i ON k.id = i.id AND
k.indid = i.indid INNER JOIN
sysobjects o ON c.id = o.id INNER JOIN
sysobjects p on p.parent_obj = o.id AND
p.name = i.name
WHERE o.type = 'U' and p.xtype = 'PK' and o.name
<> 'dtproperties'
ORDER BY o.name, i.name, k.keyno
There may be a cleaner way, would welcome comments.
Cheers.