In this step by step SQL Tutorial I will show you how to use REPLACE() function. For the purpose of this tutorial I will use SQL Server 2012.
Other Versions of SQL Server:
- SQL Server 2012
- This blog post has been written using SQL Server 2012
- SQL Server 2008 / R2
- The examples we used should work in SQL Server 2008 and R2
- SQL Server 2005
- We suspect that this will work in SQL Server 2005 as well
Who is it for?
- People who would like to learn basics of using functions.
- Those who are preparing for Microsoft certifications and need to cover this topic.
REPLACE Function - Is used to find value and replace it with specified replacement value.
REPLACE ( <<Input Value>> ,<< ValueToFind>>, <<ReplacementValue>> )
<<Input Value>> - Provide string value (field name or expression) that will be used as your input.
<<ValueToFind>> -Provide substring to be found.
<<ReplacementValue>> -Provide string to replace.
In this example I will show you how to use Replace function to. In first picture you can see that Katie&Emil company name contains '&' between names. I would like to replace '&' with 'And' you can see in second picture how I did it.
I hope That help