Row size | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Row size

I have entered few rows in my SQL Server database and was wondering, how would i determine the row size? Appreciated any help on this!
Thanks,
Cali
select sum(length) from syscolumns
where id=object_id (‘tablename’)
MohammedU.
Moderator
SQL-Server-Performance.com All postings are provided “AS IS” with no warranties for accuracy.

Try this also, got this from a friend:mad: DECLARE @sql VARCHAR (8000)
, @tablename VARCHAR (255)
, @delim VARCHAR (3)
, @q CHAR (1) SELECT @tablename = ‘{table name}’
, @q = CHAR (39) SELECT @delim = ”
, @sql = ‘SELECT ‘ SELECT @sql = @sql
+ @delim
+ ‘DATALENGTH ([‘ + name + ‘])’
, @delim = ‘ + ‘
FROM syscolumns
WHERE id = OBJECT_ID (@tablename)
ORDER BY colid SELECT @sql = @sql + ‘ rowlength’
+ ‘ FROM [‘ + @tablename + ‘]’
, @sql = ‘SELECT MAX (rowlength)’
+ ‘ FROM (‘ + @sql + ‘) rowlengths’
PRINT @sql
EXEC (@sql) Satya SKJ
Microsoft SQL Server MVP
Writer, Contributing Editor & Moderator
http://www.SQL-Server-Performance.Com
This posting is provided AS IS with no rights for the sake of knowledge sharing. Knowledge is of two kinds. We know a subject ourselves or we know where we can find information on it.
Thank you MohammedU and Satya. I ran MohammedU statement against my database and the result was "19". Does this mean, each row is 19 bytes in my user table? Also is this bytes or Kilo bytes? Appreciated some advice.
Thanks,
Cali

It is bytes not Kilo bytes…
My script gives you row lenth of a table but when you insert the data your row lenght might be different….. Note: this is not included LOB (Varchar(max), nvarchar(max) etc.) columns… MohammedU.
Moderator
SQL-Server-Performance.com All postings are provided “AS IS” with no warranties for accuracy.

]]>