RSS Feed

SQL Replace

SQL Replace

Replaces all occurrences of a specified string value with another string value.

Replace(string_1, string_2, string_3): In string_1, find exactly where string_2 occurs, and replace it with string_3.

SQL Replace can also be used to delete the occurrences of a substring.


REPLACE ( string_expression , string_pattern , string_replacement )

SQL REPLACE - Example 1

The following example replaces the string cde in abcdefghicde with xxx.

SELECT REPLACE('abcdefghicde','cde','xxx');

Here is the result set.

(1 row(s) affected)

[Source of Example 1]

SQL REPLACE - Example 2

Select Replace ('The sea is blue.', 'blue','green') From dual;

The sea is green.