Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to Get Row/Field Size

Author  Topic 

sagitariusmzi
Posting Yak Master

113 Posts

Posted - 2010-01-08 : 00:27:13
Hi,

How to get the Row size of every record / field in a table


Regard

balaganapathy.n
Starting Member

18 Posts

Posted - 2010-01-08 : 01:19:17
Hope this helps.

SELECT a.name,sum(a.max_length)as Bytes
FROM (
SELECT st.name,sc.max_length
FROM sys.columns sc inner join sys.tables st on sc.object_id = st.object_id
UNION ALL
SELECT st.name,sc.max_length
FROM sys.indexes si INNER JOIN sys.tables st ON si.object_id = st.object_id
inner join sys.columns sc on sc.object_id = st.object_id
inner join sys.index_columns sic on sc.object_id = sic.object_id
and sc.column_id = sic.column_id ) a
group by a.name
order by a.name

This gives the size (in bytes) of each column in a table.


balaganapathy n.

Anything you can imagine is real.
Go to Top of Page
   

- Advertisement -