I need to migrate data (varbinary(max)) from one table to another. When executing an update to do this, I get the following error
Msg 511, Level 16, State 1, Line 18
Cannot create a row of size 8078 which is greater than the allowable
maximum row size of 8060.
This is the update I’ve used to copy from table DocumentPublication to DocumentVersion
UPDATE docver SET RecapRTF = CAST(RTFPublication as VARBINARY(MAX)) FROM
DocumentVersion docver INNER JOIN DocumentPublication docpub
ON docpub.IdDocumentVersion = DOCVER.id
or without cast
UPDATE docver SET RecapRTF = RTFPublication FROM
DocumentVersion docver INNER JOIN DocumentPublication docpub
ON docpub.IdDocumentVersion = DOCVER.id
By executing the update row by row I’ve isolated the row that gives the error. The strange part is that the data in this field is only 3950 bytes and other rows with less or more (e.g. 2000 bytes or 20MB) work fine.
I’ve then recreated the destination table under a different name and now it can copy the varbinary field!?!?
SQL Server version is 2008 R2 with lastest updates and database with compatibility 100 (sql server 2008). I’ve run DBCC CHECKDB and DBCC CHECKALLOC and the did not find errors.
Any clues to what could be wrong here?
Your
docvertable probably has a dropped or altered column still consuming space.See Why should I rebuild a table after dropping or adding a column?