Hi There,
Worried about how to find which table contains more records, Which table consuming more space in your database.
Just simply run the Query given below. Your problem solved.
Hope it will help you!. If yes please give your comment.
Thanks
Solomon S.
Worried about how to find which table contains more records, Which table consuming more space in your database.
Just simply run the Query given below. Your problem solved.
SELECTt.NAME AS TableName,s.Name AS SchemaName,p.rows AS RowCounts,SUM(a.total_pages) * 8 AS TotalSpaceKB,CAST(ROUND(((SUM(a.total_pages) * 8) / 1024.00), 2) AS NUMERIC(36, 2)) AS TotalSpaceMB,SUM(a.used_pages) * 8 AS UsedSpaceKB,CAST(ROUND(((SUM(a.used_pages) * 8) / 1024.00), 2) AS NUMERIC(36, 2)) AS UsedSpaceMB,(SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB,CAST(ROUND(((SUM(a.total_pages) - SUM(a.used_pages)) * 8) / 1024.00, 2) AS NUMERIC(36, 2)) AS UnusedSpaceMBFROMsys.tables tINNER JOINsys.indexes i ON t.OBJECT_ID = i.object_idINNER JOINsys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_idINNER JOINsys.allocation_units a ON p.partition_id = a.container_idLEFT OUTER JOINsys.schemas s ON t.schema_id = s.schema_idWHEREt.NAME NOT LIKE 'dt%'AND t.is_ms_shipped = 0AND i.OBJECT_ID > 255GROUP BYt.Name, s.Name, p.RowsORDER BYt.Name
Hope it will help you!. If yes please give your comment.
Thanks
Solomon S.
No comments:
Post a Comment