Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

string or binary data would be truncated error Expand / Collapse
Author
Message
Posted Tuesday, May 28, 2013 12:34 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, February 18, 2014 11:27 PM
Points: 36, Visits: 183
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
Post #1457203
Posted Tuesday, May 28, 2013 7:36 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 2:32 PM
Points: 13,302, Visits: 12,168
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)
Post #1457314
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse