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) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

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

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