select o.name as 表名,c.name as 字段名,k.colid as 字段序号,k.keyno as 索引顺序
from sysindexes i
join sysindexkeys k on i.id = k.id and i.indid = k.indid
join sysobjects o on i.id = o.id
join syscolumns c on i.id=c.id and k.colid = c.colid
where o.xtype = 'U'
and exists(select 1 from sysobjects where xtype = 'PK' and name =
i.name) and o.name='emr_tyslb_ysz'--表名称
order by o.name,k.colid
from sysindexes i
join sysindexkeys k on i.id = k.id and i.indid = k.indid
join sysobjects o on i.id = o.id
join syscolumns c on i.id=c.id and k.colid = c.colid
where o.xtype = 'U'
and exists(select 1 from sysobjects where xtype = 'PK' and name =
i.name) and o.name='emr_tyslb_ysz'--表名称
order by o.name,k.colid