请问如何用sql语句查看一个表的主键,请详细说一下,谢谢
如题
------解决方案--------------------select * from (
select b.name as tblname ,a.name as colname,
主键=case when exists(SELECT 1 FROM sysobjects where xtype= 'PK ' and name in (
SELECT name FROM sysindexes WHERE indid in(
SELECT indid FROM sysindexkeys WHERE id = a.id AND colid=a.colid
))) then '√ ' else ' ' end
from syscolumns a ,sysobjects b
where a.id=b.id and b.xtype= 'u ') aa
where 主键!= ' '