2. Use
Deletes a character of the specified length and inserts another set of characters at the specified starting point.
2. Grammar
STUFF (character_expression, start, length, character_expression)
3. Example
The following example removes the three characters from the 2nd position (character B) in the first string abcdef, and then inserts a second string at the beginning of the deletion, creating and returning a string
SELECT STUFF (' abcdef ', 2, 3, ' ijklmn ') GO
Here is the result set
Aijklmnef
4. Parameters
character_expression
A character data expression. A character_expression can be a constant, a variable, a character column, or a binary data row.
Start
An integer value that specifies the start position of the delete and insert. If start or length is negative, an empty string is returned. If start is longer than the first character_expression, an empty string is returned. Start can be a bigint type.
Length
An integer that specifies the number of characters to delete. If length is longer than the first character_expression, it is removed up to the last character in the last character_expression. Length can be a bigint type.
5. Return type
If Character_expression is a supported character data type, character data is returned. If character_expression is a supported binary data type, binary data is returned.
6. Remarks
If the result value is greater than the maximum value supported by the return type, an error is generated.
Stuff function usage in SQL