select name from syscolumns a where exists ( select * from sysindexkeys b where b.id=object_id(N'表名') and a.id=b.id and a.colid=b.colid)
select name from syscolumns a where exists ( select * from sysindexkeys b where b.id=object_id(N'tb1') and a.id=b.id and a.colid=b.colid )
select a.[name], c.[name] from sysobjects a join sysindexkeys b on a.[id] = b.[id] join syscolumns c on b.[id] = c.[id] and b.colid = c.colid where a.type = 'U' and b.indid = 1
select 列名=(select name from syscolumns where id=b.id and colid=c.colid), 主键名=a.name from sysobjects a,sysindexes b,sysindexkeys c where a.xtype='pk' and a.name=b.name and b.id=c.id and b.indid=c.indid and b.id=OBJECT_ID(N'h_info')
select * from sysindexkeys b where b.id=object_id(N'表名') and a.id=b.id and a.colid=b.colid)
from syscolumns a
where exists (
select * from sysindexkeys b
where b.id=object_id(N'tb1')
and a.id=b.id and a.colid=b.colid
)
from sysobjects a join sysindexkeys b on a.[id] = b.[id]
join syscolumns c on b.[id] = c.[id] and b.colid = c.colid
where a.type = 'U' and b.indid = 1
主键名=a.name
from sysobjects a,sysindexes b,sysindexkeys c
where a.xtype='pk' and a.name=b.name and b.id=c.id and b.indid=c.indid and
b.id=OBJECT_ID(N'h_info')