This article is half-done without your Comment! *** Please share your thoughts via Comment ***
Check the below input data and expected output and perform the basic Email Validation using simple LIKE predicate.
Input Data:
1 2 3 4 5 6 |
emailname --------------------- abc@gmail.com @gmail.com abcxyz.gmail.com xyz@yahoo.com |
Expected Output:
1 2 3 4 5 6 |
emailname IsCorrectEmail -------------------------- -------------- abc@gmail.com True @gmail.com False abcxyz.gmail.com False xyz@yahoo.com True |
Create a table with sample data:
1 2 3 |
CREATE TABLE tbl_emails (emailname VARCHAR(MAX)) INSERT INTO tbl_emails VALUES ('abc@gmail.com'),('@gmail.com'),('abcxyz.gmail.com'),('xyz@yahoo.com') GO |
Solution:
1 2 3 4 5 6 7 |
SELECT emailname, CASE WHEN emailname LIKE '%_@_%_.__%' THEN 'True' ELSE 'False' END IsCorrectEmail FROM tbl_emails |
Please try the different solution for this puzzle and share it via comment...