REPLACE function | SQL Tutorial and Query Example

Text copied!

REPLACE function


  • What is a String?

    In SQL, A string is a data type used to store data that can contain combination of numbers, letters, whitespaces and symbols. In simple term, String is a word or a sequence of characters.

    What is a Substring?

    A substring is a consecutive sequence of characters or a portion of a string.

    The syntax of the REPLACE function generally looks like this :
    Here's an example of how you might use the REPLACE function :

    1. Let's assume we have a table named "[Employees]".

    REPLACE(string, substring_to_replace, new_substring)
            
    Remember :

    Using this function in a select statement won't modify the [Employees] table directly, but it will only be reflected in the select statement's output.

    To enhance your understanding of 'SQL functions', be sure to check out our next tutorial.
    REPLACE function
    SELECT REPLACE(Employee_Name, 'Mike', 'Cook')
    FROM [Employees];
            
    REPLACE function

    Frequently Asked Questions :

    Yes, there is a replace function in SQL.
    To replace part of a string in an SQL query, use the REPLACE function.
    The replace function is used to replace occurrences of a specified string with another string in a given text.
    To replace a value in a column in SQL, use the UPDATE statement with the SET clause and the WHERE clause to specify the condition.