In SQL Server, you can use the T-SQL STUFF()
function to insert a string into another string. This enables you to do things like insert a word at a specific position. It also allows you to replace a word at a specific position.
Here’s the official syntax:
STUFF ( character_expression , start , length , replaceWith_expression )
character_expression
is the original string. This can actually be a constant, variable, or column of either character or binary data.start
specifies the start position (i.e. where the new string will be inserted).length
is how many characters are to be deleted from the original string.replaceWith_expression
is the string that’s being inserted.ÂreplaceWith_expression
can be a constant, variable, or column of either character or binary data.