Stuff Function

The Stuff() function 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. It requires four (4) arguments and returns string value. A NULL value is returned if length or position is outside the length of actual string i.e. first parameter.

The syntax for Stuff function is Stuff( String , Start Location , Length , Replace With ).

SELECT Stuff('SQLDatabase.Net', 2, 3, '-') /* returns S-atabase.Net */ ;
		

SELECT Stuff('SQLDatabase.Net', 12, 1, '-') /* returns SQLDatabase-Net at location 12 the dot '.' is replaced. */ ;
SELECT Stuff('SQLDatabase.Net', Length('SQLDatabase.Net') - 3 , 1, ' is awesome to use with .') /* returns SQLDatabase is awesome to use with .Net */ ;
SELECT Stuff('SQLDatabase', 1 , 3, 'NoSQL') /* returns NoSQLDatabase */ ;
SELECT Stuff('SQLDatabase', 1 , 15, 'NoSQL') /* returns NULL since length of 15 is incorrect */ ;
SELECT Stuff('SQLDatabase', 12 , 3, 'NoSQL') /* returns NULL since start position is outside string length. */ ;
SELECT Stuff('Email at SqlDatabase.Net', 6 ,4, '@') /* returns completed email. */ ;

Stuff function is used to create other parameters, new strings.