What will you do if you want to merge two strings with each of them … in other words what will you do if you want to insert a string expression into another one using MS SQL Server ??
The STUFF function is the answer … !!
The STUFF function according to MSDN 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.
You can see the following example:
— General syntax: STUFF ( string, start, length, string )
— You will see a new string: ANegmd as a result of this built-in function.
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.
An error is raised if the resulting value is larger than the maximum supported by the return type.