Figure out what tables have records in them. The following gives a summary.
SELECT
QUOTENAME(SCHEMA_NAME(sOBJ.schema_id)) + '.' + QUOTENAME(sOBJ.name) AS [TableName]
, SUM(sPTN.Rows) AS [RowCount] into utblListOftables
FROM
sys.objects AS sOBJ
INNER JOIN sys.partitions AS sPTN
ON sOBJ.object_id = sPTN.object_id
WHERE
sOBJ.type = 'U'
AND sOBJ.is_ms_shipped = 0x0
AND index_id < 2 -- 0:Heap, 1:Clustered
GROUP BY
sOBJ.schema_id
, sOBJ.name
ORDER BY [TableName];
select * from utblListOftables
The following gives the utilzation and update stats
Select Object_Name(ix.[object_id]) as objectName
, Sum(ddius.user_seeks) As 'table_seeks'
, Sum(ddius.user_scans) As 'table_scans'
, Sum(ddius.user_lookups) As 'table_lookups'
, Sum(ddius.user_updates) As 'table_updates'
, Sum(ddius.user_seeks + ddius.user_scans) As 'query_activity'
From sys.indexes As ix
Left Join sys.dm_db_index_usage_stats ddius
On ix.object_id = ddius.object_id
And ix.index_id = ddius.index_id
Where ddius.database_id = DB_ID()
Group By Object_Name(ix.[object_id])
Order By query_activity Desc;
Comments
Post a Comment