Yesterday, I wanted to do a wildcard query on table names that included an underscore. Since the underscore is considered a wildcard for a single character, I needed a way to 'Escape' the underscore. Fortunately there is a keyword that can be used in SQL.
Example: where fieldname like '%sp^_%' ESCAPE '^'
The Escape character now is the caret.
Thursday, March 16, 2006
Subscribe to:
Post Comments (Atom)


5 comments:
Если бы мне, болельщику с 35-летним стажем, еще недавно сказали, что «Зенит» может обыграть марсельский «Олимпик» на его поле, да еще до начала своего внутреннего чемпионата, я бы вряд ли поверил.
Thank you! Your post saved me from digging around for hours, wondering why my %_% isn't doing what I think it should ...
Email me when you get the chance.
I am trying to use LIKE in the query builder of Visual Studio. My SQl reads videoTitle LIKE @search I am trying to use wildcards % but then I lose the variable @search. Do you know how I can format this?
Mark,
I believe there is another way to do this too. If you enclose the underscore in square brackets, that should work too.
For eg:
... where fieldname like '%[_]%'
should return all values of fieldname that contain an underscore.
Dinesh Mehra
Post a Comment