.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Sql Server >> Post New QuestionBookmark and Share Subscribe to Forum

How to read XML structure in SQL Server

Posted By: Mahesh     Posted Date: June 21, 2012    Points:5   Category :Sql Server
How to read XML structure in SQL Server

Responses
Author: Mahesh             
Posted Date: June 21, 2012     Points: 20   

DECLARE @xml XML
SET @xml = (SELECT id, fname, lname FROM customers WHERE id in (161,162) FOR XML PATH('customers'))

SELECT
x.d.value('id[1]','INT') AS id,
x.d.value('fname[1]','VARCHAR(50)') AS fname,
x.d.value('lname[1]','VARCHAR(50)') AS lname
FROM @xml.nodes('/customers') x(d)



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend