In this article I am trying to illustrate a vary useful function of SQL Server called STUFF.
Stuff is a T-SQL Function used to delete a specified length of characters within a string and replace with another set of characters.
STUFF(Character_expression1, start, length, Character_expression2)
Represents the string in which the stuff function is to be applied.
It indicates the starting position of the character in the string of Character_expression1.
The length of the characters, which need to be replaced.
It is the string that will be replaced to the start position.
SELECT STUFF(‘joydeep’, 2, 3, ‘xxxxx’)
Here “o” is the starting position 2, so from position 2 it takes 3 character “oyd” and replace it by “xxxxx”.
Posted by: MR. JOYDEEP DAS