Create XML using SQL Query in SQL Server 2008

Here, we will learn how to create XML using Query: SELECTTOP1000 [Code]       ,[Name]       ,[Price]   FROM[Temp].[dbo].[Product]   FORXML RAW (‘Product’),   ROOT (‘Products’); Here SQL statement “FOR XML RAW” creates one XML node for every corresponding row in database and columns will be created as attributes of that XML node. Results: <Products> <ProductCode=”1″Name=”Computer”Price=”100.0000″/> <ProductCode=”2″Name=”Mobile”Price=”250.0000″/> </Products> SQL ELEMENTS create […]

Read More