Change Domain Name in Email ID SQL SERVER
Recently my organization has changed his domain name, so this will also effect our HR portal. Because our HR portal is authenticate users from AD(Active Directory) also checks users status in HR database which reside on SQL SERVER. My manager asked me to change domain name from abc.com to bac.comĀ with minimum downtime and without intruptrting users services.
So I used replace function of SQL SERVER, it’s easy to use and solved my problem. It replaces abc. Phrase to bac. Phrase easily. It took only few seconds and services are running smoothly.
Script:-
------CREATE TABLE----------- CREATE TABLE [DBO].[TABLE_1]( [ID] [INT] NULL, [EMAIL] [VARCHAR](50) NULL ) GO ------INSERT RECORD INTO TABLE------ INSERT INTO TABLE_1 VALUES(1,'I@GOOGLE.COM') INSERT INTO TABLE_1 VALUES(2,'IFO@GOOGLE.COM') INSERT INTO TABLE_1 VALUES(3,'INO@GOOGLE.COM') INSERT INTO TABLE_1 VALUES(4,'IF@GOOGLE.COM') INSERT INTO TABLE_1 VALUES(5,'I1O@GOOGLE.COM') INSERT INTO TABLE_1 VALUES(6,'I11NFO@GOOGLE.COM') INSERT INTO TABLE_1 VALUES(7,'INF1111@GOOGLE.COM') GO -----UPDATE EMAIL FIELD------- UPDATE TABLE_1 SET EMAIL = REPLACE (EMAIL,'GOOGLE.','FACEBOOK.') GO -----SELECT DATA FROM TABLE------ SELECT * FROM TABLE_1 GO