STUFF Function in SQL Server 2008

In this article i will explain how to use STUFF Function in SQL.
  • 3172

Introduction

STUFF() function is used to delete a certain length of the string and a new string is inserted at the deleted place. It is used to stuff a string into another string.

Syntax

STUFF (InputString, start, length, ReplaceString)

where,

InputString- Input string specifies the string in which replacement is to be done.
start- starting point from where string is to be replaced.
length- number of characters to be replaced

Example

 Suppose we have table named Employee as.

CreateTable-in-sqlserver.jpg

Replace four characters of L_Name column  to "XX" from 2nd position in Employee table.

SQL-STUFF-function.jpg

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.