21

Can you please let me know how do I resolve this problem while inserting xml data into Sql Server 2008

ex = {"String or binary data would be truncated.\r\nThe statement has been terminated."}

I already replaced ', "" with an empty string

thanks in Advance

3 Answers 3

26

Please check the datetype of the column. Make sure it has enough space.

1
  • 3
    How to know which column is causing the problem
    – Charlie
    Oct 29, 2018 at 6:56
20

Check the Database Column Size and Data length. you will get this error when you are storing data of length greater than that of defined size.

    Ex. string Data = "saving this data causes error.";
    int datalength = Data.Length;  // will be 30 characters , greater than defined size

    Customer.Name = Data;
    //you will get error for this line if you have Name (varchar 25, null) in db      .
1

If you're using a subquery change the = between the sub query and main query to in.

It may be that you have more than one field for each record of the main query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.