Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 How to find the text with % in it.

Author  Topic 

Shadab Shah
Starting Member

23 Posts

Posted - 2012-07-23 : 01:55:03
Hi,

Suppose following are the content of my table,

empname
abc%def
xyzpqr
mnopqr
st%vwx

i would like to fire a query which would give me the output as

empname
abc%def
st%vwx

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-07-23 : 02:20:39
try:

where empname like '%[%]%'


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Bill_C
Constraint Violating Yak Guru

299 Posts

Posted - 2012-07-23 : 02:22:43
I think it's something like:-

SELECT empname from table1 WHERE empname LIKE '%[%]%'
Go to Top of Page

Bill_C
Constraint Violating Yak Guru

299 Posts

Posted - 2012-07-23 : 02:23:07
oops, beat me to it - lol

Any special characters being searched on go inside square brackets.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-07-23 : 10:55:44
also

SELECT empname from table1 WHERE empname LIKE '%!%%' ESCAPE '!';


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -