Reputation: 3983
I would like to exclude spam mails. Normally spam mails has [email protected]
How can i check in MSSQL if mail has this syntax. Somehow with regex?
SELECT * FROM mytable WHERE mycolumn REGEXP "^.*[^0-9][0-9]{2}$";
Upvotes: 0
Views: 197
Reputation: 1271231
I think your description of what a spam email looks like may be a bit outdated. But, if you want to exclude such emails in SQL Server, you can -- with a bit of effort.
SQL Server does not support regular expressions, but it does support an enhanced like
. So, you can do:
where email not like '%.%.%@%' or
email not like '%[^0-9]%.%.%@$' or
email not like '%.%[^0-9]%.%@$'
This implements three conditions:
Combined, these are equivalent to your condition.
Upvotes: 1