SQL Server 2012 查询数据库中所有表的索引信息
2021-04-08 19:26
501 查看
查询语句如下:
with temp as( select a.name as tabname,a.object_id ,h.name as indexName,h.index_id,ic.column_id,c.name colName from sys.objects as a right join sys.indexes as h on a.object_id=h.object_id left join sys.index_columns ic on h.index_id=ic.index_id and ic.object_id=a.object_id left join sys.columns c on ic.column_id=c.column_id and c.object_id=a.object_id where a.type<>'s' and a.type='U' --and isnull(h.name,'')='' --没有索引的表 and a.is_ms_shipped<>1 --排除 dtproperties ) select distinct temp.tabname,indexName ,stuff(( select ',' + tc.name from sys.columns tc left join sys.index_columns ic on ic.column_id=tc.column_id and ic.object_id=temp.object_id where tc.object_id=temp.object_id and ic.index_id=temp.index_id and tc.column_id in ( select column_id from temp where object_id=tc.object_id and ic.index_id=temp.index_id ) for xml path('') ),1,1,'' ) columnName from temp order by temp.indexName
相关文章推荐
- SQL Server查询数据库所有存储过程、触发器、索引信息SQL分享
- SQL Server查询数据库所有存储过程、触发器、索引信息SQL分享
- SQL Server查询数据库所有存储过程、触发器、索引信息SQL分享
- SQL Server查询所有存储过程信息、触发器、索引
- SQL Server查询所有存储过程信息、触发器、索引
- SQL Server查询所有存储过程信息、触发器、索引
- 查询所有SQL用户的连接信息(可显示IP)\SQL Server中强制关闭数据库连接
- sql server 查询所有表的字段的详细信息的存储过程(在 SQL Server 2005 中查询表结构及索引 )
- SQL Server 2012 查询数据库中所有表的名称和行数
- postgresql数据库查询所有索引详细信息,包括描述信息
- sqlserver查询数据库所有存储过程、触发器、索引信息
- MS SQL 查询数据库中所有索引以及对应的表字段 SQL Server Profiler性能跟踪
- Sql server 2005 查询某个数据库下的所有表的记录行数
- 数据库” 查询选修所有课的学生信息“ exists解法的理解
- Sql Server 查询表结构和索引信息
- 查询数据库表的所有外键信息
- 列出SQL SERVER 数据库所有表信息的sql 语句
- [SQL Server] 查询索引信息.
- sqlserver2005 查询数据库所有表的字段信息
- sql server 2012 数据库所有表里查找某字符串的方法