Thursday, March 8, 2012

Cannot create a row of size %d which is greater than the allowable maximum of %d

I'm trying to execute an insert with a PreparedStatement object and I am getting the following Error message:

java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot create a row of size 8320 which is greater than the allowable maximum of 8060.

Does anyone have a solution for this?You're inserting data that is larger than the maximum page size for SQL Server. See this page (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/trblsql/tr_reslsyserr_1_20hd.asp).|||Originally posted by Mulligan
You're inserting data that is larger than the maximum page size for SQL Server. See this page (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/trblsql/tr_reslsyserr_1_20hd.asp).

Thanks for the link. I had already taken a look there before finding this forum but I couldn't understand why my data was longer than the page size for SQL because I was only inserting a small amount of data.

I found that my problem due to MS SQL creating a temporary table based on my Insert Statement using the table definition for the size of the columns. In this case, I had a nvarchar(4000) column. This then generated a temp table with a column size equivalent to 8363 bytes but the page size is 8060. This happens even though the data I was inserting was much smaller than the max length.

To resolve the problem I had to reduce to the column size to a maximum of 3868. This resolved the problem.|||Nice bit of detective work. And thanks for posting back with the solution - it makes a refreshing change from all the "How can I fix problem X?" "Like this." "Bye" postings :)

Mull.

No comments:

Post a Comment