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.
| Author |
Topic |
|
rmg1
Constraint Violating Yak Guru
256 Posts |
Posted - 2011-04-08 : 07:45:20
|
| Hi allI've got some character strings which contain a "_" (which is normally a wildcard).I want to be able to search for things like "_OH_" as a string and treat the "_" as part of the string not as a wildcard.Anyone any ideas? |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-04-08 : 07:48:18
|
put square brackets around it:where col1 like '%[_]OH[_]%' No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
ms65g
Constraint Violating Yak Guru
497 Posts |
Posted - 2011-04-08 : 07:51:48
|
OrWHERE PATINDEX('_OH_', col) > 0;______________________ |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-04-08 : 07:56:15
|
quote: Originally posted by ms65g OrWHERE PATINDEX('%_OH_%', col) > 0;______________________
No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
rmg1
Constraint Violating Yak Guru
256 Posts |
Posted - 2011-04-08 : 07:56:23
|
| Thanks folks, works perfectly. |
 |
|
|
ms65g
Constraint Violating Yak Guru
497 Posts |
Posted - 2011-04-08 : 08:02:08
|
| Replace patindex with charindex______________________ |
 |
|
|
|
|
|