how to escape % when doing Like filter?

  • Sorry no DDL, but can some one still offer help with syntax. I just need to have result where the field countername begins with a % (as percent) character. The below returns everything having word 'usage', 'idle', 'processor' , thereby returning more rows than I need.

    How to modify this so SQL knows I'm looking only for values starting with %?

    where countername like '%usage%'

    or countername like '%idle%'

    or countername like '%processor%'

  • Something like this?

    where countername like '[%]usage%'

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • this what worked

    where countername like '%[%]%usage%'

    or countername like '%[%]%idle%'

    or countername like '%[%]%processor%'

  • That will return all countername values containing a percentage sign before the word, not only the ones that start with the percentage sign.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

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

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