How to Find and REPLACE in SQL Query

The purpose of REPLACE function is to replace one string with another string.

REPLACE Function

REPLACE (string, find, replace) – The result is a string with the replaced value as given inside of this function. You can learn more SQL Functions for SQL programmer.

Examples:

REPLACE('5555-555-1212','-','.') 
- Result is '5555.555.1212'
REPLACE('559-555-1212','-','')
- Result is '5595551212'
VALUES CHAR (REPLACE ('DINING', 'N', 'VID'), 10)
-Result is 'DIVIDIVIDG'.VALUES
REPLACE ('The quick brown fox', 'QUICK', 'LARGE')
- Result is 'The LARGE brown fox'

Rules to follow

  • If the actual length of the replace-string exceeds the maximum for the return data type, an error is returned.
  • If any argument can be null, the result can be null; if any argument is null, the result is the null value.

Related Posts

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.