Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


string or binary data would be truncated error


string or binary data would be truncated error

Author
Message
balaji.ganga 68339
balaji.ganga 68339
SSC Rookie
SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)

Group: General Forum Members
Points: 39 Visits: 220
Hi

There is a " string or binary data would be truncated error " raised while executing the stored procedure. The stored procedure get inserts the records into the table. There is a column called " path " . and the length is 50 - varchar type. But actually the length of the incoming value is 40 character only. But still the error is occurred. I should not increase the length of the field.

incoming data is given below. it is trying to insert the values into path field.

select datalength(REPLICATE(' ',1) + LTRIM('Case(' + convert(varchar, 3050722) + ') --> ') + '(' + CONVERT(VARCHAR(20),11200) + ':' + CONVERT(VARCHAR(20),3157054) + ') --> ')
as length

Does anyone knows the answer ? please guide me

Regards
Balaji G
Sean Lange
Sean Lange
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16542 Visits: 16997
balaji.ganga 68339 (5/28/2013)
Hi

There is a " string or binary data would be truncated error " raised while executing the stored procedure. The stored procedure get inserts the records into the table. There is a column called " path " . and the length is 50 - varchar type. But actually the length of the incoming value is 40 character only. But still the error is occurred. I should not increase the length of the field.

incoming data is given below. it is trying to insert the values into path field.

select datalength(REPLICATE(' ',1) + LTRIM('Case(' + convert(varchar, 3050722) + ') --> ') + '(' + CONVERT(VARCHAR(20),11200) + ':' + CONVERT(VARCHAR(20),3157054) + ') --> ')
as length

Does anyone knows the answer ? please guide me

Regards
Balaji G


Do you know 100% that is the column that is causing the issue? Is that the only column that is being inserted?

Why all the crazy functions and such for what is just a hard coded value? REPLICATE(' ', 1)????

You could make that whole big functioned stuff be as simple as this:


select DATALENGTH(' Case(3050722) --> (11200:3157054) --> ') as length



_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search