查询SQL重复索引,索引重复检测

select * from (
    select tableName,colName,COUNT(1) as icount,min(indexName) as indexname from (
        select*from(
            select  d.name as tableName,c.name as colName ,a.name as indexName,d.type
            from sys.indexes a, sys.index_columns b ,sys.columns c ,sys.objects d
            where a.index_id=b.index_id 
            and a.object_id=d.object_id
            and b.column_id=c.column_id
            and b.object_id=d.object_id
            and b.object_id=c.object_id
            and d.type='U'
        ) a
    ) a group by tableName,colName 
) a where icount>1

猜你喜欢

转载自blog.csdn.net/zbs5010/article/details/87930250
今日推荐