How to ignore Apostrophes ' and comments -- while updating

  • Hi,

    I have a varchar(8000) field. I have to update it periodically appending it. But the string contains reserved characters.

    For example The' Big -- Blue Fox 'Jumped Over the fen'ce but couldn't

    When I tried to take this string into a variable I am getting an error.

    I know the work around is to put in double apostrophes, but this is live data.

    Is there a way you can do it?

    Thanks

    Vishy Dhara

  • So this is your original data:

    The' Big -- Blue Fox 'Jumped Over the fen'ce but couldn't

    Turn off quoted identifer and add a double quote at the beginning and end works for this example.

    [font="Courier New"]SET QUOTED_IDENTIFIER OFF

    declare @myVar varchar(100)

    set @myVar = "The' Big -- Blue Fox 'Jumped Over the fen'ce but couldn't"

    select @myVar as result

    result

    ----------------------------------------------------------

    The' Big -- Blue Fox 'Jumped Over the fen'ce but couldn't

    (1 row(s) affected)[/font]

    /Kenneth

  • Thanks a lot!

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

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