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
Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Yesterday @ 12:25 PM
Points: 705, Visits: 1,657
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


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Yesterday @ 12:55 PM
Points: 4,046, Visits: 9,200
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
Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Yesterday @ 12:25 PM
Points: 705, Visits: 1,657
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


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Yesterday @ 12:55 PM
Points: 4,046, Visits: 9,200
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