SQL Flow Field Guide

REPLACE

Catalog support for SQL Server 2022 (16.x) and 2025 (17.x)

string transform

What changes

Input
string arguments
Output or change
string or integer
Return type
Returns nvarchar if one of the input arguments is of the nvarchar data type; otherwise, REPLACE returns varchar. Returns NULL if any one of the arguments is NULL. If string_expression is not of type v

Syntax at a glance

REPLACE ( string_expression , string_pattern , string_replacement )

Work example

Replace a literal substring while preparing a display value.

Test case and collation behavior and cast to a max type when the output can exceed 8,000 bytes.

Check your work REPLACE compares using the input collation and can truncate non-max results at 8,000 bytes.

Practice SQL

Open in SQL Flow
SELECT REPLACE('North-East', '-', ' ') AS label;

Open Microsoft Learn for full syntax, permissions, and details for your version.