我正在尝试查找基于数据类型 uniqueIdentifier 的列构建的所有聚集索引。显然,这对于聚集索引来说是一个糟糕的选择,我正试图找到所有这些并删除它们。到目前为止,我编写的脚本会返回每个具有唯一标识符的表的所有聚集索引。请帮忙。这是脚本:
select distinct object_name(i.object_id) AS tablename, i.name AS indexname, i.type_desc as type
from sys.indexes i
join sys.index_columns ic on ic.object_id = i.object_id and ic.index_id = i.index_id
join sys.columns c on c.column_id = ic.index_column_id
join sys.types t on t.system_type_id = c.system_type_id
join sys.objects o on o.object_id = i.object_id
where t.name = 'uniqueidentifier'
and i.type_desc = 'clustered'
and object_name(i.object_id) not like 'sys%'