April 29, 2014 at 3:51 am
Hi,
Is there any query available to find the size of each row of a table?
Thanks.
April 29, 2014 at 4:00 am
Quick solution, you will have to sum up each row though
😎
USE AdventureWorks2012;
GO
DECLARE @TABLE_NAMESYSNAME= N'SalesOrderDetail';
DECLARE @TABLE_SCHEMASYSNAME= N'Sales';
DECLARE @SQL_STRNVARCHAR(MAX)= N''
SELECT
@SQL_STR = N'SELECT '+
STUFF((SELECT ',DATALENGTH(' + C.COLUMN_NAME + N') AS [DL_' + C.COLUMN_NAME + N']' AS [text()]
FROMINFORMATION_SCHEMA.COLUMNS C
WHEREC.TABLE_NAME=@TABLE_NAME
ANDC.TABLE_SCHEMA=@TABLE_SCHEMA
FOR XML PATH (''), TYPE).value('.[1]','NVARCHAR(MAX)'),1,1,N'')
+N' FROM '
+@TABLE_SCHEMA
+NCHAR(46)
+@TABLE_NAME
+N''
--SELECT @SQL_STR
EXEC (@SQL_STR)
April 29, 2014 at 4:08 am
You can also see the below link
April 29, 2014 at 7:45 am
Whenever I see this type of request I have to ask, what are trying to accomplish here? What can you gain by knowing how much storage is consumed by each and every row? I am intrigued by what use this might actually have.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply