Tuesday, 26 January 2016

STUFF in SQL Server



The STUFF function inserts a string into another string. It deletes a specified length of characters in the first string at the start position and then inserts the second string into the first string at the start position.
Syntax:
STUFF (character_expression , start , length , replaceWith_expression)

Ex:
Select * From Employee;


Select STUFF((
 Select ', ' + Name
 From employee
 For XML Path('')
),1,1,'') as Names;


Select STUFF((
 Select ', ' + Name
 From employee
 Order by Name
 For XML Path('')
),1,1,'') as Names;





1 comment:

  1. About the SQL server information was very good and it is very useful in my studies and the easy to observe in provides coding information.
    dotnet

    ReplyDelete