Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

how to escape % when doing Like filter? Expand / Collapse
Author
Message
Posted Tuesday, March 25, 2014 12:40 PM
Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Tuesday, May 12, 2015 11:03 PM
Points: 789, Visits: 1,905
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%'
Post #1554644
Posted Tuesday, March 25, 2014 12:50 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 8:44 PM
Points: 5,328, Visits: 12,049
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?


Forum Etiquette: How to post data/code on a forum to get the best help
Post #1554648
Posted Tuesday, March 25, 2014 12:52 PM
Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Tuesday, May 12, 2015 11:03 PM
Points: 789, Visits: 1,905
this what worked
where countername like '%[%]%usage%'
or countername like '%[%]%idle%'
or countername like '%[%]%processor%'
Post #1554649
Posted Tuesday, March 25, 2014 12:59 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 8:44 PM
Points: 5,328, Visits: 12,049
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?


Forum Etiquette: How to post data/code on a forum to get the best help
Post #1554651
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse