QUESTION POSED ON: 29 August 2007 Is it possible to search for a row or rows with particular strings containing an underscore? Suppose I have various email addresses all containing an underscore like gm_ace@where.com, hj_bus@ where.com, etc. How can I search for those particular emails? If I use a WHERE clause such as 'WHERE eMail LIKE '%_' it returns all rows. 'WHERE eMail LIKE 'gm_%' returns rows that do not contain an underscore. Can you offer any suggestions?
To continue reading for free, register below or login
Requires Membership to View
To read more you must become a member of SearchSQLServer.com
The underscore character is a single character wildcard in the same way the percent sign is a multi-character wild card. To query for an underscore character you need to wrap the underscore in square brackets: WHERE email LIKE 'gm[_]%'. If you want to search for all email addresses with a two character value then an underscore, this WHERE clause would work: WHERE email like '__[_]%@%'.
Search and Browse the Expert Answer Center Search and browse more than 25,000 question and
answer pairs from more than 250 TechTarget industry experts.
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.