There are situations when user want to change some portion of the data inserted. The reason may be because of the human error or the change in data. For this purpose, stuff() function comes to action.
STUFF() :
In SQL Server, stuff() function is used to delete a sequence of given length of characters from the source string and inserting the given sequence of characters from the specified starting index.
Syntax:
STUFF (source_string, start, length, add_string)
Where:-
1. source_string: Original string to be modified.
2. start: The starting index from where the given length of characters will be deleted and new sequence of characters will be inserted.
3. length: The numbers of characters to be deleted from the starting index in the original string.
4. add_string: The new set of characters (string) to be inserted in place of deleted characters from the starting index.
Note: It is not necessary to have the length of the new string and number of charaters to be deleted the same.
Example 1:

Output:

Example 2:

Output:

Example 3:

Output:

Recommended Posts:
- Difference between Structured Query Language (SQL) and Transact-SQL (T-SQL)
- SQL Server LAG() function Overview
- SQL Server LEAD() function Overview
- NTILE() Function in SQL Server
- RANK() Function in SQL Server
- Delete statement in MS SQL Server
- SQL Server Mathematical functions (SQRT, PI, SQUARE, ROUND, CEILING & FLOOR)
- SQL Server Identity
- SQL SERVER | Conditional Statements
- SQL Server | SERVERPROPERTY()
- Mean and Mode in SQL Server
- Allow only alphabets in column in SQL Server
- SQL SERVER | IN Condition
- Difference between MySQL and MS SQL Server
- Comparisons between Oracle vs SQL Server
- Introduction of MS SQL Server
- Select statement in MS SQL Server
- Order by in MS SQL Server
- Distinct clause in MS SQL Server
- Where clause in MS SQL Server
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

