October 9, 2007 at 6:52 am
Can anyoen plase let me know if theres any query which can return the total length/bytes used for all column in a table. any help on thsi will be greatly appreciated.
TIA
October 9, 2007 at 7:54 am
select * from information_schema.columns where table_name = 'Customers'
will give you the max length of the values, but the issue is that each row can have different data. What exactly are you planning on using this for?
October 9, 2007 at 8:00 am
Basically i want to know how much total bytes(by all columns) is occupied in a table . i woked it out anyway. Thanks so much for the help..
select sum(length) from syscolumns
where id in (select id from sysobjects
where name = )
October 9, 2007 at 8:31 am
Space is row length * rows.
So you can work out the max for a row, but it doesn't give you space used by a table. There are other scripts that can help you calculate that.
October 9, 2007 at 2:24 pm
Hopefully this is what you want:
SELECT db_name(database_id) as db
, object_name(object_id,database_id) as table_name
, min_record_size_in_bytes
, avg_record_size_in_bytes
, max_record_size_in_bytes
FROM
sys.dm_db_index_physical_stats(NULL, NULL, NULL, NULL , 'DETAILED')
WHERE db_name(database_id) NOT IN ('master','model','msdb','tempdb','distribution','ReportServer', 'ReportServerTempDB')
AND index_id = 1 -- clustered;
ORDER BY max_record_size_in_bytes desc
* Noel
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply