stuff

The stuff function inserts a string into another string. It deletes a specified length of characters in expr1 at the start position. It then inserts expr2 string into expr1 string at the start position. If the start position or the length is negative, a NULL string is returned.

If the start position is longer than expr1, a NULL string is returned. If the length to delete is longer than expr1, it is deleted through the last character in expr1. For example:

select stuff("abc", 2, 3, "xyz") 
---- 
axyz 
 
(1 row affected) 

To use stuff to delete a character, replace expr2 with NULL, not with empty quotation marks. Using “ ” to specify a null character replaces it with a space.

select stuff("abcdef", 2, 3, null)
--- 
aef

(1 row affected)
select stuff("abcdef", 2, 3, "")
---- 
a ef 
 
(1 row affected)