SQL Server: How to replace string in SQL Server

Here i will give an example how to replace a substring in a string in SQL Server. 
For example you want to change domain in Employee email addresses in 'EmployeeDetails' table.

In the below example i am replacing  EmailId  from "@gmail.com" to "studentboxoffice.in" in 'EmployeeDetails' Table .

Example: 1)

Declare @txt1 varchar(50)
set @txt1 = 'vikramreddy@gmail.com'

/* Here i am replacing @gmail.com to @studentboxoffice.in */

set @txt1 = REPLACE(@txt1, '@gmail.com', '@studentboxoffice.in')

select @txt1

-- Output:

Exmple: 2)

You can also update employee emailid in 'EmployeeDetails' table. 

-- before update EmailID = 'vikramreddy@gmail.com'

update    EmployeeDetals 
set        EmailID = REPLACE(EmailID, '@gmail.com', '@studentboxoffice.in')
where    EmployeeCode = 3151

-- After updating EmailID = 'vikramreddy@studentboxoffice.in'