The usage of SQL Server stuff function
1. Function
Deletes characters of the specified length and inserts another set of characters at the specified starting point.
2. Grammar
STUFF (character_expression, start, length, character_expression2)
3. Explanation
Character_expression is the string to be processed
Start is the starting position of the deleted character, and the string starts at 1. If you want to delete from the second character, the start is 2.
The length of the character to be deleted by length. If you delete from the second character and delete three characters, the length is 2.
Character_expression2 wants to replace the deleted string (it's a bit of a mouthful, but it's not hard to understand)
4. Examples
If the preprocessed string character_expression is' abcdef', wants to delete 'cde', the stuff function is written as follows:
Stuff ('abcdef',3,3,'')
If you want to replace 'cde' with' xyz', the stuff function is written as
Stuff ('abcdef',3,3,'xyz')