stuff

Description

Returns the string formed by deleting a specified number of characters from one string and replacing them with another string.

Syntax

stuff(char_expr1 | uchar_expr1, start, length, char_expr2 | uchar_expr2)

Parameters

char_expr1

is a character-type column name, variable, or constant expression of char, varchar, nchar or nvarchar type.

uchar_expr1

is a character-type column name, variable, or constant expression of unichar or univarchar type.

start

specifies the character position at which to begin deleting characters.

length

specifies the number of characters to delete.

char_expr2

is another character-type column name, variable, or constant expression of char, varchar, nchar or nvarchar type.

uchar_expr2

is another character-type column name, variable, or constant expression of unichar or univarchar type.

Examples

Example 1

select stuff("abc", 2, 3, "xyz")

---- 
axyz

Example 2

select stuff("abcdef", 2, 3, null)

go
--- 
aef

Example 3

select stuff("abcdef", 2, 3, "")

---- 
a ef

Usage

Standards

SQL92 – Compliance level: Transact-SQL extension.

Permissions

Any user can execute stuff.

See also

Functions replicate, substring