What is the difference between STUFF and REPLACE in SQL Server? Example.

STUFF: Using the stuff function we delete a substring of a certain length of a string and replace it with a new string. 

REPLACE: As the function name replace indicates, the replace function replaces all occurrences of a specific string value with another string.

Example

SELECT STUFF('kul shresth',1,3,'nagar')
SELECT REPLACE('kulshresth kumar','kumar','nagar')
Share:

No comments:

Post a Comment

Thursday, 5 September 2019

What is the difference between STUFF and REPLACE in SQL Server? Example.

STUFF: Using the stuff function we delete a substring of a certain length of a string and replace it with a new string. 

REPLACE: As the function name replace indicates, the replace function replaces all occurrences of a specific string value with another string.

Example

SELECT STUFF('kul shresth',1,3,'nagar')
SELECT REPLACE('kulshresth kumar','kumar','nagar')

No comments:

Post a Comment

Popular

Total Pageviews

Archive