SQL Database Concepts Question:
Download Questions PDF

Tell me what is the STUFF and how does it differ from the REPLACE function?

Answer:

Both STUFF and REPLACE are used to replace characters in a string.

select replace('abcdef','ab','xx') results in xxcdef

select replace('defdefdef','def','abc') results in abcabcabc
We cannot replace a specific occurrence of “def” using REPLACE.

select stuff('defdefdef',4, 3,'abc') results in defabcdef

where 4 is the character to begin replace from and 3 is the number of characters to replace.

Download Basic SQL Server Interview Questions And Answers PDF

Previous QuestionNext Question
What is BCP?How to store pdf file in sql server?