Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine row size for table

How to I determine the maximum row size for a table? I'm looking for a tool or script that does this so I don't have to add up each column's size by hand.

My goal is to produce a report of tables that are too wide so we can look into restructing them. I know we have several that are so wide that only 1 row fits on each 8K page, but I want to find the rest.

like image 651
Jonathan Allen Avatar asked Jan 30 '09 17:01

Jonathan Allen


People also ask

How do you calculate rows in a table?

To count the number of rows, the “#Table_Id tr” selector is used. It selects all the <tr> elements in the table. This includes the row that contains the heading of the table. The length property is used on the selected elements to get the number of rows.

How do I find the row size of a table in SQL Server?

Below is a SQL query to find row size. The query uses DATALENGTH function, which returns the number of bytes used to represent a column data. A row may consist of fixed, variable data types. A varchar is a variable datatype which means that a varchar(50) column may contain a value with only 20 characters.

What is row size in SQL Server?

MS SQL server allows only 8060 bytes of data max to be stored in a row. Hence your row size will always be <= 8060. But it is relaxed when a table contains varchar, nvarchar, varbinary, sql_variant, or CLR user-defined type colums.


1 Answers

Another way, run this then look at MaximumRecordsize

dbcc showcontig ('YourTableNameHere') with tableresults 
like image 129
SQLMenace Avatar answered Oct 02 '22 11:10

SQLMenace