Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 12963

Warning: maximum row size exceeds the allowed maximum of 8060 - even when my table is below 8060

$
0
0

Hello,

We have SQL Server 2008 R2 (SP2) - 10.50.4000.0 (X64)   Jun 28 2012 08:36:30  Standard Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1) (Hypervisor) .

I need your help as I've been really puzzled about this warning.

Here's exactly what I get except for table's name: xxxx.

"Warning: The table "xxxxx" has been created, but its maximum row size exceeds the allowed maximum of 8060 bytes. INSERT or UPDATE to this table will fail if the resulting row exceeds the size limit."

When I did manual calculation of my column sizes + null block + header block, I find the value below 8060. Here's actual calculation:

Datatype & counts:

datetime = 17 columns

int = 47 columns

smallint = 1 column

varchar = 313 columns

Sum of varchar lengths: 6813, calculated using this query:

   SELECT sum(character_maximum_length)

  FROM [xxxxx].[INFORMATION_SCHEMA].[COLUMNS]

  where TABLE_NAME='xxxxxx' and DATA_TYPE='varchar'


1 datetime field = 8 bytes

1 int field = 4 bytes

1 smallint = 2 bytes

Header row = 4 bytes

Creation of varchar field = 2 bytes

Each varchar field by itself = 2 bytes

NULLABILITY of fields, which goes like 2 bytes for NULL block creation + 1 byte for every 8 nullable fields.  We have 377 nullable fields in xxxxx table, so 377/8 = 47.1 which will calculate as 48 bytes, so 50 bytes total for null fields.

Final calculation = 4 + (17*8) + (47*4) + (2*1)+2+(313*2)+6813 +50 = 7771

So, unless I've mixed another metric to account for, why would SQL server give such warning if it's still below 8060 ? Maybe I need to reset something ? I've dropped some columns before this calculation.


Viewing all articles
Browse latest Browse all 12963

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>