This Is Why REPLACE Function Is So Famous!

Replace in SQL
How to write effective SQL Queries with REPLACE

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

The syntax for REPLACE function is:

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.


REPLACE('5555-555-1212','-','.') - Result is '5555.555.1212'REPLACE('559-555-1212','-','') - Result is '5595551212'
VALUES REPLACE ('The quick brown fox', 'QUICK', 'LARGE')
- Result is 'The LARGE brown fox'.

Rules for Replace:

  • 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.

Author: Srini

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