Use of the REPLACE function in SQL Server, serverreplace
REPLACE
Replace all the second given string expressions in the first string expression with the third expression.
Syntax
REPLACE (''string _ replace1 '', ''string _ replace2'', ''string _ replace3 '')
Parameters
''String _ replace1''
String expression to be searched. String_replace1 can be character data or binary data.
''String _ replace2''
String expression to be searched. String_replace2 can be character data or binary data.
''String _ replace3''
String expression used for replacement. String_replace3 can be character data or binary data.
Return type
If string_replace (1, 2, or 3) is one of the supported character data types, character data is returned. If string_replace (1, 2, or 3) is one of the supported binary data types, binary data is returned.
Example
In the following example, replace the string cde in abcdefghi with xxx.
Select replace (''abcdefghicde'', ''cde'', ''xxx') GO
The following is the result set:
------------ Abxxxfghixxx (1 row (s) affected)
Articles you may be interested in:
- Sqlserver replace Function
- The data type ntext of parameter 1 of the replace function in SQL is invalid.
- MySQL replace function replacement string statement usage
- Replace MYSQL character replacement function SQL statement sharing (Regular Expression judgment)
- MSSQL error: the parameter data type text is invalid for parameter 1 of the replace function.
- SQL SERVER uses REPLACE to REPLACE a value in a field in a column with another value.