1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
USE tempdb
GO
create table #NoClusteredIndex (
[Database Name] sysname,
[TableName] varchar(256),
[Recordcount] bigint
)
DECLARE @CMD VARCHAR(MAX)
SET @CMD = N'use [?]
select db_name() as databasename,o.name,sum(p.rows) as recordcount
from sys.objects o
Join sys.partitions p on p.object_id=o.object_id
where o.type= ''U''
and o.object_id not in
(select object_id from sys.indexes where type_desc=''CLUSTERED'')
group by o.name,o.object_id,p.rows
--order by p.rows desc'
Insert into #NoClusteredIndex
exec sp_MSForEachDB @CMD
select [Database Name],[TableName],[Recordcount]
from #NoClusteredIndex
where [Database Name] not in('master','msdb','model','tempdb')
and [Recordcount]>10000
order by [Recordcount] desc
drop table #NoClusteredIndex |
Partager