Mask Your Email Address – SQL SERVER

If you want to mask your email addressess on your development or test environment so developers or any other person cannot abuse the data.
Here is the script which replaces couple of characters of the email.
CREATE TABLE #TEST01
(
ID int ,
Email nvarchar(30),
)

 

 

INSERT INTO #TEST01 VALUES(1,'user2011@test1.com')
INSERT INTO #TEST01 VALUES(2,'johndoe@gmail.com')
INSERT INTO #TEST01 VALUES(3,'doenam@yahoo.com')
INSERT INTO #TEST01 VALUES(4,'yoyo@hotyomail.org')
INSERT INTO #TEST01 VALUES(5,'sami1978@ymail.com')
SELECT * FROM #TEST01
UPDATE #TEST01
SET Email = REPLACE(REPLACE(REPLACE(Email, '.co', '.go'),
'a', 'c'), 'y', 'g')
SELECT * FROM #TEST01
-- DELETE FROM #TEST01
-- DROP TABLE #TEST01

 

 

Leave a Reply