February 24, 2010 at 2:20 pm
I have created a script (eventually to be converted to a stored proc) that creates a table with a dynamic name, then inserts data from several tables into it. After it's converted into a stored proc it'll be used in the UI of my web app - so this is all to prepare for that purpose.
I have one table with a fair amount of text in it (TEXT data type) where the insert into the temp table fails with the error of "Msg 8152, Level 16, State 13, Line 1 String or binary data would be truncated." The data type of the column in the temp table is TEXT and it is the same in the originating table, yet it fails.
Here's some of the code:
==============================================
declare @Tmp_table VARCHAR(30)
...
...
...
-- Create the temporary table
execute ('create table ' + @Tmp_table + ' (TableName NVARCHAR(100), NGHost NVARCHAR(100), [Desc] TEXT, LastUpdate DATETIME, Removed BIT)')
-- Populate the table
Execute ('insert into ' + @Tmp_table +
' select ''table1'',table1.nghost, table1.[desc], table1.LastUpdate, table1.removed
from table1, table2
where table1.id = table2.fk_nghost')
========================================
So, this is collecting all the data from several tables and all (seven tables) are collected properly but the last one fails with the ever-descriptive-and-impossible-to-misunderstand error of "Msg 8152, Level 16, State 13, Line 1 String or binary data would be truncated."
Could it be a caching or buffer limitation I need to overcome to make this TEXT to TEXT data type work considering the amount of text being inserted (about 8000 characters)?
TIA...
February 25, 2010 at 7:11 am
A couple of comments. If you are really using SQL Server 2005 then you should not be using the Text data type you should be using the varchar(max) data type. Secondly, your error is probably not the the Text column but one of the other string columns. I'd do a LEN() on each column in the source table to see if the destination columns are large enough.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply