SQL Server REPLACE() Function | sql server text replace function
ExampleReplace"T"with"M":SELECTREPLACE(SQLTutorial,T,M);TryitYourself»[1]DefinitionandUsageTheREPLACE()functionreplacesalloccurrencesofasubstringwithinastring,withanewsubstring.Note:Thesearchiscase-insensitive.Tip:AlsolookattheSTUFF()[2]function.SyntaxREPLACE(string,old_string,new_string)ParameterValuesParameterDescriptionstringRequired.Theoriginalstringold_stringRequired.Thestringtobereplacednew_stringRequired.ThenewreplacementstringTechnicalDetailsWorksin:SQLServer(startingwith2008),AzureS...
ExampleReplace "T" with "M":
SELECT REPLACE(SQL Tutorial, T, M);
Try it Yourself »[1] Definition and UsageThe REPLACE() function replaces all occurrences of a substring within a string, with a new substring.
Note: The search is case-insensitive.
Tip: Also look at the STUFF()[2] function.
SyntaxREPLACE(string, old_string, new_string)
Parameter Values Parameter Description string Required. The original string old_string Required. The string to be replaced new_string Required. The new replacement string Technical Details Works in: SQL Server (starting with 2008), Azure SQL Database, Azure SQL Data Warehouse, Parallel Data Warehouse More Examples ExampleReplace "SQL" with "HTML":
SELECT REPLACE(SQL Tutorial, SQL, HTML);
Try it Yourself »[3] References Try it Yourself » (www.w3schools.com) STUFF() (www.w3schools.com) Try it Yourself » (www.w3schools.com)