Is it possible to search for a row or rows with particular strings containing an underscore?
By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
Suppose I have various email addresses all containing an underscore like email@example.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?
The underscore character is a single character wildcard in the same way the percent sign is a multi-character wildcard. 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 '__[_]%@%'
Dig Deeper on Microsoft SQL Server Performance Monitoring and Tuning
Related Q&A from Denny Cherry
To avoid performance problems when running multiple instances of SQL Server 2005 with Exchange on Windows SBS, refer to these expert best practices.continue reading
After installing SQL Server 2005, the SQL Server tools may not appear in the start menu. Our expert explains how to troubleshoot this problem.continue reading
Find out where to look for the current amount of SQL Server database disk space being used in your environment.continue reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.