SQL determine table row size

Personal note: See my SQL Monitor project


SELECT SCHEMA_NAME(so.schema_id) AS schemaname, OBJECT_NAME (sc.[id]) tablename
, COUNT (1) nr_columns
, SUM (sc.length) maxrowlength
FROM syscolumns sc
join sys.all_objects so on sc.[id] = so.[object_id]
--join sys.schemas s on so.schema_id = s.schema_id
WHERE so.is_ms_shipped = 0
GROUP BY so.schema_id, OBJECT_NAME (sc.[id])
ORDER BY SUM (sc.length) desc


SELECT SCHEMA_NAME(so.schema_id) AS schemaname, OBJECT_NAME (sc.[id]) tablename
, COUNT (1) nr_columns
, SUM (sc.length) maxrowlength
FROM syscolumns sc
join sys.all_objects so on sc.[id] = so.[object_id]
--join sys.schemas s on so.schema_id = s.schema_id
WHERE so.is_ms_shipped = 0
AND OBJECT_NAME(sc.id) = 'Orders'
GROUP BY so.schema_id, OBJECT_NAME (sc.[id])
ORDER BY SUM (sc.length) desc


dbcc showcontig ('Production.Orders') with tableresults

Table space used


EXEC sp_spaceused 'Product.Operations'

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: