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 主键!=''
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 主键!=''