REPLACE() Function in SQL Server
Table of Content:
REPLACE function replaces all occurrences of a specified string value with another string value.
Syntax:
REPLACE(String_Expression, Pattern , Replacement_Value)
Example: All .COM strings are replaced with .NET
Code:
Select Email, REPLACE(Email, '.com', '.net') as Email from TableEmployee
Prerequisite Code
CREATE TABLE TableEmployee( FirstName varchar(50), LastName varchar(50), Email varchar(50) ) INSERT INTO TableEmployee VALUES('Rambo', 'Azmi', 'Rambo@aaa.com') INSERT INTO TableEmployee VALUES('Azam', 'Ali', 'Azam@aaa.com') INSERT INTO TableEmployee VALUES('Inza', 'Hoque', 'Rambo@aaa.com') INSERT INTO TableEmployee VALUES('Jaman', 'Sk', 'Jaman@aaa.com') INSERT INTO TableEmployee VALUES('Samser', 'Alam', 'Samser@aaa.com') SELECT * FROM TableEmployee