Lookin For an Escape

  • This one is embarassing, but I can't get it figured out, so I am asking for help.

    I am trying to pass a query to a string, and I want to use Like in the WHERE clause. But I don't know how to pass in the single quote marks.

    eg

    @sqlquery = 'SELECT ErrorMsg FROM ErrorTable WHERE ErrorMsg LIKE 'Critical%' '

    Can anyone help?

    Thanks

    Jeff

    Edited by - jwt on 07/22/2003 07:08:01 AM

    Edited by - jwt on 07/22/2003 07:09:11 AM

  • Here you go

    @sqlquery = 'SELECT ErrorMsg FROM ErrorTable WHERE ErrorMsg LIKE ' + '''Critical%'''

    Laters

    *I didn't do anything it just got complicated*


    "I didn't do anything it just got complicated" - M Edwards

  • Thanks!

    BTW is that one double and one single quote around critical, or is it three singles?

  • Hi,

    Sorry wasn't very readable was it. Three singles each side.

    Laters

    *I didn't do anything it just got complicated*


    "I didn't do anything it just got complicated" - M Edwards

  • This was what I was doing - only I was trying to do it all in one string rather than using the concatination of the string with the escape characters....

    So now I know - and knowing is half the battle.

  • You can do it all in one - just put two single quotes instead of one. e.g.

    @sqlquery = 'SELECT ErrorMsg FROM ErrorTable WHERE ErrorMsg LIKE ''Critical%'' '

Viewing 6 posts - 1 through 5 (of 5 total)

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