Link to home
Start Free TrialLog in
Avatar of anushahanna
anushahannaFlag for United States of America

asked on

Find data size from syscolumns,sysobjectssys.partitions,columns

The following query brings the table's # of rows, but what join is needed to bring the data size also?

Thanks
select isc.TABLE_SCHEMA,so.name,SUM(sc.length) AS ROW_SIZE_IN_BYTES,sp.rows as TotRows
from sysobjects so join syscolumns sc on so.name = OBJECT_NAME(sc.id)
join INFORMATION_SCHEMA.COLUMNS isc on sc.name=isc.COLUMN_NAME and so.name=isc.TABLE_NAME
join sys.partitions sp on OBJECT_NAME(sp.object_id)=so.name
where so.type = 'U' GROUP BY so.name, isc.TABLE_SCHEMA,sp.rows;

Open in new window

Avatar of anushahanna
anushahanna
Flag of United States of America image

ASKER

If data size for the table can be derived, it will be nice to have the sum of all the index size also for that table.
ASKER CERTIFIED SOLUTION
Avatar of Raja Jegan R
Raja Jegan R
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks.
Welcome..