|
STUFF
Delete characters of the specified length and insert another set of characters at the specified starting point.
grammar
STUFF (character_expression, start, length, character_expression)
parameter
character_expression
An expression composed of character data. character_expression can be a constant, a variable, or a column of character or binary data.
start
Is an integer value that specifies the start position of deletion and insertion. 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.
length
Is an integer that specifies the number of characters to be deleted. If length is longer than the first character_expression, delete up to the last character in the last character_expression.
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.
Comment
String functions can be nested.
Example
The following example creates and returns a string by deleting three characters from the second position (character b) in the first string (abcdef), and then inserting the second string at the beginning of the deletion.
SELECT STUFF('abcdef', 2, 3,'ijklmn')
GO
Here is the result set:
---------
aijklmnef
(1 row(s) affected) |
|