Posts

Showing posts with the label Stuff Vs. Replace Vs. Substring

Stuff Vs. Replace Vs. Substring

Image
Stuff: Using the stuff function we can remove a substring of a certain length of a string and replace it with a new string. Refer the following arguments that we need to pass to the Stuff function: Stuff, Replace and Substring functions in SQL Server First argument passed to the function is the expression. Second argument is the starting length from where the new characters are to be added. Third argument tells how many characters to allocate to the new string being embedded. Fourth argument takes the new string to be embedded as a parameter. 1 2 3 declare @ text varchar ( 50 )    set @ text = 'Welcome to .Net Snippets'    select @ text as Title    Let us run this and check the output. Stuff, Replace and Substring functions in SQL Server We will now add some characters to this string. See the following Stuff function. 1 select STUFF ( @ text , 24 , 3 , '!!' ) as Title It will ...