|
I am trying to load a sql statement into a column which is varchar(8000) The sql is only 200 lines so it can't be reaching the limit of the column but I'm getting an error of "String binary data would be truncated" when I try to insert the sql Statement Terminated How do i work around this?
(comments are locked)
|
|
Are you sure that all 200 lines of code you are inserting are 40 characters or less?
(comments are locked)
|
|
The error message doesn't lie - You are hitting the limit of the column. Take a look at:
That should give you a start
(comments are locked)
|
|
Don't forget that each line break could be two characters (carriage-return AND linefeed - the joys of having conventions hanging over from real typewriters); leading tabs / spaces also count where they wouldn't in a wordcount. Are the blank lines blank, or loaded with spaces? Have you removed trailing spaces from the lines?
(comments are locked)
|
|
copy the TSQL into a word processing app and check the properties to see how many characters there are or split the code into two and assign each piece to a variable and check the LEN property
(comments are locked)
|
|
I can add some observation even though other answers have already covered it. Generally speaking, it is ill advised to create a table which has in_row_data potential size exceeding 8060 bytes. While SQL Server 2008 (and probably even latest pack of 2005) will allow you to do so because SQL Server 2008 has an additional storage area for in_row_data overflows, it is still a bad idea. It is easy enough to opt for varchar(max) instead of varchar(8000) in those scenarios because the former is considered a BLOB and does not have to be stored in row while the latter is always stored in row thus making the records unnecessary wide (allowing only 1 record per page should the varchar(8000) column be filled completely). Here is the script which is terrible but runs just fine in SQL Server 2008: The above happily creates a table and inserts 2 records despite the fact that the second record totalling 8226 bytes is wider than 8060 bytes which a data page can hold. I don't have SQL Server 2000 database handy but I remember that the table like this would be created (with warning) but then the first insert would succeed and the second - fail with error. The error can be suppressed and the record - allowed to be inserted by settting the ansi_warnings off, but the results of such a chicanery would be far from desired because some 160 odd characters would be chopped off. Oleg I do not believe this is the exact thing happening in the code but may explain some "refinements" needed
Aug 30 '11 at 08:53 AM
siera_gld
(comments are locked)
|


200 lines or 200 characters?
200 lines -
can we see the query which you are using ???
Thank you for all your input - I am waiting for end user feedback and will resume work in a day or so