Created
August 24, 2023 16:21
-
-
Save itspluxstahre/3509f43b47f9449d9ba5b0d76a607626 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
[email].[id] | |
,CASE | |
WHEN [TED_CI].[email] IS NULL | |
THEN NULL | |
WHEN | |
CHARINDEX(' ',LTRIM(RTRIM([TED_CI].[email]))) = 0 | |
AND LEFT(LTRIM([TED_CI].[email]),1) <> @ | |
AND RIGHT(RTRIM([TED_CI].[email]), 1) <> '.' | |
AND CHARINDEX('.', [TED_CI].[email] ,CHARINDEX('@',[TED_CI].[email])) - CHARINDEX('@', [TED_CI].[email]) > 1 | |
AND LEN(LTRIM(RTRIM([TED_CI].[email]))) - LEN(REPLACE(LTRIM(RTRIM([TED_CI].[email])),'@','')) = 1 | |
AND CHARINDEX('.',REVERSE(LTRIM((RTRIM([TED_CI].[email]))))) >= 3 | |
AND (CHARINDEX(.@, [TED_CI].[email]) = 0 AND CHARINDEX('..', [TED_CI].[email]) = 0) | |
AND LEFT([TED_CI].[email], charindex('@', [TED_CI].[email]) -1) NOT LIKE '%[^A-z0-9!#$%&*+\-/=?^_{|}~.]%' ESCAPE '\' | |
AND RIGHT([TED_CI].[email], LEN([TED_CI].[email]) - charindex('@', [TED_CI].[email])) NOT LIKE '%[^A-Za-z0-9.-]%' | |
THEN TRIM([TED_CI].[email]) | |
ELSE NULL | |
END AS [mail] | |
FROM [dbo].[vTED_contactInfo] [TED_CI] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment