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
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Tuesday, September 16, 2014 8:10 AM
Points: 656, Visits: 1,533
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


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: 2 days ago @ 2:04 PM
Points: 3,572, Visits: 8,008
Something like this?

where countername like '[%]usage%'




Luis C.
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
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Tuesday, September 16, 2014 8:10 AM
Points: 656, Visits: 1,533
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


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: 2 days ago @ 2:04 PM
Points: 3,572, Visits: 8,008
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.
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