Tuesday, 19 April 2016

Use of STUFF function in SQL Server?

Stuff function is used to replace the occurrence of the String in a Expression based on the start value and length value.

Syntax : 

STUFF ([CHARACTER EXPRESSION],[START],[LENGTH],[REPLACEMENT STRING]

Example :

SELECT STUFF('JK SQLBLOG',7,1,'SERVER ') 

In above example replacement string 'SEVER' will be Inserted in the character expression.
It search for the character position 7 in the character expression and after that it will insert the replacement string.

Output :

JK SQLSERVER LOG


No comments:

Post a Comment