应该如此:
select name as PK_name -- 主键的名字
,object_name(id) as Table_name -- 相关表的名字
,keycnt as KeyCnt --涉及的列的数量
,key1 as Key1 --涉及的第一个列
,key2 as Key2 --涉及的第二个列(如果有的话)
,key3 as Key3 --涉及的第三个列(如果有的话)
from sysindexes
where indid > 0
and status2 & 2 = 2
and status & 2048 = 2048