日期:2014-05-18 浏览次数:20678 次
--结合sys.indexes和sys.index_columns,sys.objects,sys.columns查询索引所属的表或视图的信息 select o.name as 表名, i.name as 索引名, c.name as 列名, i.type_desc as 类型描述, is_primary_key as 主键约束, is_unique_constraint as 唯一约束, is_disabled as 禁用 from sys.objects o inner join sys.indexes i on i.object_id=o.object_id inner join sys.index_columns ic on ic.index_id=i.index_id and ic.object_id=i.object_id inner join sys.columns c on ic.column_id=c.column_id and ic.object_id=c.object_id go --查询索引的键和列信息 select o.name as 表名, i.name as 索引名, c.name as 字段编号, from sysindexes i inner join sysobjects o on i.id=o.id inner join sysindexkeys k on o.id=k.id and i.indid=k.indid inner join syscolumns c on c.id=i.id and k.colid=c.colid where o.name='表名'
------解决方案--------------------