Try the following:
- summarize the lengths of all columns
select SUM(sc.length) from syscolumns sc inner join systypes st on sc.xtype = st.xtype where id = object_id('table')
- Look at the returned items
select st.name, sc.* from syscolumns sc inner join systypes st on sc.xtype = st.xtype where id = object_id('table')
However, there are no guarantees, but it seems the same length is displayed in sp_help 'table'
DISCLAIMER: Please note that I read an article related to John Rudy, and in addition to the maximum sizes here, you also need other things like NULL bitmap to get the actual line size. Also, the dimensions are maximum. If you have a varchar column, the actual size is smaller for most rows ....
Vendoran has a nice solution, but I don't see the maximum row size anywhere (based on the definition of the table). I see the average size and all kinds of placement information, which is exactly what you need to estimate the size of the database for most things.
If you are only interested in what sp_help returns for length and adds it, I think (I'm not 100% sure) that a request to sysobjects returns the same numbers. Do they represent the full maximum row size? No, you are missing things like NULL bitmap. Are they a realistic indicator of your evidence? Not. VARCHAR (500) does not accept 500 bytes if you only store 100 characters. Also, TEXT fields and other fields stored separately from the line do not display their actual size, just the size of the pointer.
Cervo
source share