SQL Reference

Quick Reference

The SQL Server STUFF() function deletes a part of a string, starting at a specified position, and then inserts a new part into the string at that position.

SELECT STUFF('1SMARTchicken', 7, 7, 'duck');

Output

1SMARTduck

Syntax

STUFF(string, start, length, new_string)

Parameters

ParameterDescription
stringThe string to be modified (required)
startThe position in the string to start deletion (required)
lengthThe number of characters to delete from the string (required)
new_stringThe new string to insert into the string at the start position (required)

SQL Notes:

  • Any work being done to modify the structure of a database or delete tables or the the database itself should only be done after making a recent backup

We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.