SQL Server 2000/5 Escape an Underscore *

Question

How do I escape the underscore character?

I am writing something like the following where clause and want to be able to find actual entries with _d at the end.

Where Username Like '%_d'

Answer

T-SQL Reference for LIKE for SQL Server 2000:

You can use the wildcard pattern matching characters as literal characters. To use a wildcard character as a literal character, enclose the wildcard character in brackets. The table shows several examples of using the LIKE keyword and the [ ] wildcard characters.

For your case:

... LIKE '%[_]d'
< br > via < a class="StackLink" href=" http://stackoverflow.com/questions/5821/" >SQL Server 2000/5 Escape an Underscore< /a>
Share on Google Plus

About Cinema Guy

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment