SQL Server: REPLACE Function

The REPLACE() function in SQL Server replaces certain text (substring) with new text (substring) in a string value.

Syntax:

REPLACE(input_string, substring, new_substring);

In this syntax

  • input_string is the original string/text to be searched.
  • substring is the part of the text in input_string that will be searched for and replaced with new text/characters. 
  • new_substring is the new text/character that will replace the substring text.

e.g. Text that manually typed:


e.g. text from column value of table.


REPLACE function can also be used in an UPDATE query.

Initial data:


Updated data:




Post a Comment

0 Comments