select a.[name] as TableName, b.[name] as KeyName
from sysobjects a
join syscolumns b on a.[id] = b.[id]
join sysindexkeys c on a.[id] = c.[id] and b.colid = c.colid
where a.xtype = 'U' and c.indid = 1
order by a.[Name], b.colid
from sysobjects a
join syscolumns b on a.[id] = b.[id]
join sysindexkeys c on a.[id] = c.[id] and b.colid = c.colid
where a.xtype = 'U' and c.indid = 1
order by a.[Name], b.colid
sp_pkeys 'tablename'