column has a single quotation causing error

  • Hello,

    while trying to insert records to a table making joins between several tables, its found that one column has such entry with a single quote (for e.g, Record'ng date is on Feb 2010 t0 -678659x). Can I either use quotename() function or do you suggest some escape function in order to load the data? Kindly suggest.

    Error msg:

    Msg 8152, Level 16, State 4, Line 1

    String or binary data would be truncated.

    The statement has been terminated.

    Thanks.

  • You must be using some dynamic SQL for the process, and that dynamic script is built incorrectly.

    This is the part you need to fix.

    _____________
    Code for TallyGenerator

  • Double any existing single quotes in the data:

    ... + REPLACE(data, '''', '''''') /*make every ' in the data become '' */ + ...

    SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.

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

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