What is the STUFF function and how does it differ from the
REPLACE function?

Answers were Sorted based on User's Feedback



What is the STUFF function and how does it differ from the REPLACE function?..

Answer / abhaymalviya

STUFF - Delete a specified length of characters and insert
another set of characters at a specified starting point.
For example: SELECT STUFF('asdfghjkl', 3, 5, 'XYZ')
Go
here the result set is:

asXYZkl

REPLACE - Replace all occurrences of the second given string
expression in the first string expression with a third
expression.
For Example: SELECT REPLACE('Abhay', 'a', 'KKT')
Here the result set is:

KKTbhKKTy


Is This Answer Correct ?    37 Yes 1 No

What is the STUFF function and how does it differ from the REPLACE function?..

Answer / ruchi

STUFF - Delete a specified length of characters and insert
another set of characters at a specified starting point.
For example: SELECT STUFF('asdfghjkl', 3, 5, 'XYZ')
Go
here the result set is:

asXYZkl

REPLACE - Replace all occurrences of the second given string
expression in the first string expression with a third
expression.
For Example: SELECT REPLACE('Abhay', 'a', 'KKT')
Here the result set is:

KKTbhKKTy

Is This Answer Correct ?    9 Yes 6 No

Post New Answer

More SQL Server Interview Questions

Does table partitioning improve performance?

0 Answers  


Is truncate a dml command?

0 Answers  


Can we perform backup restore operation on tempdb? : sql server database administration

0 Answers  


When to use Inner join & when to use subquery?

0 Answers   IBM,


What is the difference between DTS and SSIS?

3 Answers   Allianz,






Can group by be used without aggregate functions?

0 Answers  


What happens if you delete a table that is used by a view?

0 Answers  


Can you get second highest salary from the table?

0 Answers   QuestPond,


When do you use SQL Profiler?

3 Answers   Wipro,


In the primary key have a multiple field or not?

8 Answers   TCS,


How to find Duplicate Records In table?

0 Answers   HCL,


what is meant by sql injection with example and one more question how to catch the errors in sqlserver

2 Answers  


Categories