Categories:

This query helps you identify your tables and calculate size/rowcount ratio easily:

USE [DatabaseName] -- replace your

GO

SELECTs.NameASSchemaName,t.NameASTableName,p.rowsASRowCounts,CAST(ROUND((SUM(a.used_pages) / 128.00), 2) ASNUMERIC(36, 2)) ASUsed_MB,CAST(ROUND((SUM(a.total_pages) - SUM(a.used_pages)) / 128.00, 2) ASNUMERIC(36, 2)) ASUnused_MB,CAST(ROUND((SUM(a.total_pages) / 128.00), 2) ASNUMERIC(36, 2)) ASTotal_MBFROMsys.tables tINNERJOINsys.indexes i ONt.OBJECT_ID = i.object_idINNERJOINsys.partitions p ONi.object_id = p.OBJECT_ID ANDi.index_id = p.index_idINNERJOINsys.allocation_units a ONp.partition_id = a.container_idINNERJOINsys.schemas s ONt.schema_id = s.schema_idGROUPBYt.Name, s.Name, p.RowsORDERBYs.Name, t.Name

GO

Tags:

No responses yet

Bir cevap yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir