string or binary data would be truncated error

  • 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

  • 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 Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply