REPLACE (SQL Server Compact)

Replaces all occurrences of the second given string expression in the first string expression with a third expression.

Syntax

REPLACE ( 'string_expression1' , 'string_expression2' ,'string_expression3' )

Arguments

  • ' string_expression1 '
    The string expression to be searched. The string_expression1 argument can be of data types that are implicitly convertible to nvarchar or ntext.

  • ' string_expression2 '
    The string expression to try to find. The string_expression2 argument can be of data types that are implicitly convertible to nvarchar or ntext.

  • ' string_expression3 '
    The replacement string expression. The string_expression3 argument can be of data types that are implicitly convertible to nvarchar or ntext.

Return Value

nvarchar or ntext

Returns NULL if any of the arguments is NULL.

Example

The following example searches for the name "Anton" in the list of product names and replaces it with "Anthony".

SELECT REPLACE([Product Name], 'Anton', 'Anthony')
FROM Products