Hi
What is the STUFF function and how does it differ from the REPLACE function ?
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Jul 12, 2012, 8:15 AM EDT
http://www.c-sharpcorner.com/blogs/888/replace-vs-stuff-in-sql-server-2005.aspx
Satyapriya NayakRank #47 · 31.5K reputationPosted Jul 12, 2012, 9:58 AM EDT
STUFF function to overwrite existing characters. Using this syntax, STUFF(string_expression, start, length, replacement_characters), string_expression is the string that will have characters substituted, start is the starting position, length is the number of characters in the string that are substituted, and replacement_characters are the new characters interjected into the string.
REPLACE function to replace existing characters of all occurance. Using this syntax REPLACE(string_expression, search_string, replacement_string), where every incidence of search_string found in the string_expression will be replaced with replacement_string.
Please refer the below links
http://blog.sqlauthority.com/2007/04/19/sql-server-interview-questions-part-5/
Thanks
Jignesh TrivediRank #16 · 50.3K reputationPosted Jul 12, 2012, 8:08 PM EDT
Stuff : This function can be used for delete a certain length of the string and insert a new string in the deleted place.
STUFF ( InputString, start, length, ReplacedString )
Replace : This function replaces all the occurrences of a string expression with a new string within an input string.
REPLACE ( InputString , StringToReplace , NewString )
http://sqlserverpedia.com/blog/sql-server-bloggers/sql-functions-%E2%80%93-stuff-and-replace/
hope this will help you.