Quote Identified Problem.

  • Please someone help.  My data is like this:

    BookId       Notes

    111           My aunt's favorite book is self-help

    My job will failed if it sees a single quote like that, but it will work with

    My aunt''s favorite book is self-help.

    How can I go around this?

    I want to update my notes field to 2 single quotes to prevent the failure of the job. 

    Thanks in advance.

    Minh Vu 

     

  • Well, to do what you want, this would work:

    UPDATE MyTable

    set Notes = REPLACE(Notes, '''', '''''')

     

    But more importantly, tell us why / how your job is failing and we should be able to help you out.

  • Don't use dynamic SQL.

    But if you really need to use dynamic SQL learn how to use parameters with sp_executesql.

    _____________
    Code for TallyGenerator

  • This is what you do you use double quotes around words with apostrophe.  Try the link below for more about using delimiters.

     

     My "aunt's" favorite book is self-help.

     

     Hope this helps.

     

    http://msdn2.microsoft.com/en-US/library/ms176027.aspx

     

    Kind regards,

    Gift Peddie

     

    Kind regards,
    Gift Peddie

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

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