This topic contains and tries to cover following subjects
- Explanation of REPLACE () function in SQL
- Syntax of REPLACE () function in SQL
- Example to REPLACE () function in SQL
Articles contains and tries to provide answer to following questions and issues:
- What is REPLACE () function
- How to use REPLACE () function..
- How to replace a string with another string in a column of a table
Articles may require following knowledge:
- Basic query flow in SQL
- SQL Server Management Studio
- SQL Server string functions
Explanation of REPLACE() function in SQL
REPLACE function can be used to replace a string with another string . For example, we can search occurrences in a nvarchar text to replace them with the specified string .
Syntax of REPLACE () function in SQL
Syntax for REPLACE () function is as follows:
LEN ( source string , string to be replaced , string as replacement )
Example of REPLACE () function in SQL
To demonstrate how to replace a string with another with searching all occurrences, we will test it in a SELECT query.
Query is as follows:
As above query execution result indicates, the provided text "SQL server 2012" is checked for occurrence of 2012, and 2012 pattern occurrences are replaced with 2014.