SQL SERVER FOR XML PATH
hi,
Today i was reading my mails found some interesting feature in sql server 2005 and 2008 FOR XML PATH. FOR XML Path can be used to generate XML Format data from SQL Queries.
I used it for Concat String Value (CSV) For Column
XML PATH Syntax
Select STUFF( ( Select Top 10 ',' + AccountName From Mastccount Order by ID For XML PATH('') ) ,1,1,'') as CSV
Output
Switin,Jitesh,Rupesh,...............................
Note :- Stuff is to Remove the Addition , which comes on the start of String--Concat process is done by For
Greate stuff from MS.
Find out more from
http://msdn2.microsoft.com/en-us/library/ms345137.aspx
http://sqljunkies.com/WebLog/mrys/archive/2004/02/19/1208.aspx
Today i was reading my mails found some interesting feature in sql server 2005 and 2008 FOR XML PATH. FOR XML Path can be used to generate XML Format data from SQL Queries.
I used it for Concat String Value (CSV) For Column
XML PATH Syntax
Select STUFF( ( Select Top 10 ',' + AccountName From Mastccount Order by ID For XML PATH('') ) ,1,1,'') as CSV
Output
Switin,Jitesh,Rupesh,...............................
Note :- Stuff is to Remove the Addition , which comes on the start of String--Concat process is done by For
Greate stuff from MS.
Find out more from
http://msdn2.microsoft.com/en-us/library/ms345137.aspx
http://sqljunkies.com/WebLog/mrys/archive/2004/02/19/1208.aspx
Comments
Post a Comment