8.24.2012

Difference between STUFF and REPLACE in SQL Server

Difference between STUFF and REPLACE in SQL Server
S.No
STUFF
REPLACE
1
STUFF is used to replace the part of string with some other string.
REPLACE is used to replace all the occurances of the given pattern in a string.
2
Syntax:
STUFF (stringexpression, start, length, replacementcharacters)
Example:
SELECT STUFF('Umar's Blog is USEFUL',8,4,'DATABASE')
Output:
Umar's DATABASE is USEFUL
Syntax:
REPLACE ( string_expression , string_pattern , string_replacement )
Example:
select Replace('Umar','U','A')
Output: Amar

2 comments: