sql string replace code example

Example 1: sql query with replace function

##sql query with replace function
#syntax
UPDATE tableName
SET  column_name = REPLACE(column_name, 'fromStringValue', 'toStringValue');

#Example 
Update  tbl_employee
Set designation = REPLACE(designation, 'SEO', 'Developer');

Example 2: sql replace character in string in all records

UPDATE employees 
SET 
    phone_number = REPLACE(phone_number, '.', '-');

Example 3: replace string value in sql

UPDATE tableName  SET  fieldName = REPLACE(fieldName, 'fromStringValue', 'toStringValue');

Example 4: replace function in sql

REPLACE function: This function is used 
to replace the existing characters
of all the occurrences.

Example 5: stuff and replace in sql

STUFF Function: This function is used to
overwrite existing character or inserts
a string into another string. 

REPLACE function: This function is used 
to replace the existing characters
of all the occurrences.

Tags:

Sql Example