Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 String would be truncated message on text data

Author  Topic 

Mondeo
Constraint Violating Yak Guru

287 Posts

Posted - 2010-01-14 : 05:51:11
Hi,

I have a field with data type text

When I try and add data to it i'm getting "string or binary data would be trucated"

Not sure why i'm getting that message with a text field?

Thanks

Kristen
Test

22859 Posts

Posted - 2010-01-14 : 06:54:54
Is the truncation happening in a Procedure Parameter (that is perhaps not TEXT datatype), or something like that?

Error message should tell you the line number in the SQL block where the problem is arising, and the name of the object - for example, it might be in a Trigger
Go to Top of Page

davidc
Starting Member

26 Posts

Posted - 2010-01-14 : 06:55:57
You may be trying to add text to a column which is not larger enough. Try increasing column size e.g. varchar(20) if your longest text is 20 characters
Go to Top of Page

Mondeo
Constraint Violating Yak Guru

287 Posts

Posted - 2010-01-14 : 06:56:10
I'm trying to copy the string directly into the field in management studio. I've checked the length and its 4200 bytes.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-01-14 : 07:29:50
"I've checked the length and its 4200 bytes."

I presume that's the length of the data you are inserting (not the size of the column, as that is TEXT)?

I think management studio is restricted to 8000 characters for VARCHAR and 4000 for NVARCHAR in "grid" mode. If I've remembere that correctly that's probably your problem.

Writing an UPDATE / INSERT statement in a Query window would allow you to handle larger text. Make sure you find and replace any embedded single-quotes to escape them.
Go to Top of Page
   

- Advertisement -