I have this query that pulls email addresses from our DB. There is a lot of junk data, so I only want to see valid email addresses. Here is my syntax:
SELECT DISTINCT Email
FROM dbo.Customers
WHERE (Email IS NOT NULL)
AND (Email LIKE '%@%')
AND (RIGHT(Email, 4) IN ('.net', '.com', '.org'))
AND (Email NOT LIKE '%@UniformCity.com')
AND (Email NOT LIKE '%@LifeUniform.com')
AND (RIGHT(RTRIM(Email), 1) <> '.') AND (LEFT(LTRIM(Email), 1) <> '@') --first character not @
AND (Email not Like '%[`:;_*-,()+%\/=#-]%') order by Email
I want to detect periods at the beginning of the email. Also as a bonus, how can I tell my like statement to look for “[” without screwing it up?
How about
For the
[], you could just change the escape character?http://msdn.microsoft.com/en-us/library/ms179859.aspx