Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

REPLACE (SQL Server Compact)

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


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

' 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.

nvarchar or ntext

Returns NULL if any of the arguments is NULL.

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
Show:
© 2015 Microsoft