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

LVL 6
anushahannaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

anushahannaAuthor Commented:
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.
0
Raja Jegan RSQL Server DBA & Architect, EE Solution GuideCommented:
try this simple one:
create table temp ( name varchar(100), rows int, reserved varchar(100), data varchar(100), index_size varchar(100), unused varchar(100));
EXEC sp_MSforeachtable @command1=" insert into temp EXEC sp_spaceused '?'";
select * from temp;

-- drop table

drop table temp

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
anushahannaAuthor Commented:
Thanks.
0
Raja Jegan RSQL Server DBA & Architect, EE Solution GuideCommented:
Welcome..
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.