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: Today @ 5:33 PM
Points: 605, Visits: 1,411
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%'


it helps to talk it out
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: Today @ 6:22 PM
Points: 3,359, Visits: 7,270
Something like this?

where countername like '[%]usage%'




Luis C.
I am a great believer in luck, and I find the harder I work the more I have of it. Stephen Leacock

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: Today @ 5:33 PM
Points: 605, Visits: 1,411
this what worked
where countername like '%[%]%usage%'
or countername like '%[%]%idle%'
or countername like '%[%]%processor%'


it helps to talk it out
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: Today @ 6:22 PM
Points: 3,359, Visits: 7,270
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.
I am a great believer in luck, and I find the harder I work the more I have of it. Stephen Leacock

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