Using STUFF

The STUFF function inserts a string into another string. It deletes a specified length of characters in the first string at the start position and then inserts the second string into the first string at the start position.

If the start position or the length is negative, or if the starting position is larger than length of the first string, a null string is returned. If the length to delete is longer than the first string, it is deleted to the first character in the first string.

This example puts in the character string of “xyz” starting at the second character of the “abc” character expression, and replaces a total of three characters.

SELECT STUFF('abc', 2, 3, 'xyz')

  

Here is the result set:

----

axyz

  

(1 row(s) affected)

  

See Also

String Functions

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.