SQL Flow Field Guide

STUFF

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 character data if character_expression is one of the supported character data types. Returns binary data if character_expression is one of the supported binary data types.

Syntax at a glance

STUFF ( character_expression , start , length , replace_with_expression )

Work example

Delete a range of characters and insert replacement text at a position.

Test Unicode, trailing spaces, collation, empty input, and maximum output length.

Check your work Use one-based positions and test start, length, empty source, and Unicode input.

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