.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 get required XML structure in sql query

Posted By: Mahesh     Posted Date: June 21, 2012    Points:5   Category :Sql Server
How to get required XML structure in sql query

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

Try this query,
-------------------------------
SELECT (SELECT * FROM Customers FOR XML AUTO, TYPE).query(
'<doc>{
for $c in /Customers
return
<Person name="{data($c/@FIRST_NAME)}"/>
}</doc>')
--------------------------------

Other query will be as
------------------------
SELECT
'Chemistry' as '@testType',
'Bilirubin, Direct' as 'displayText',
'' as 'universalServiceId',
LNUM as 'universalServiceId/id' ,
SNAME as 'universalServiceId/name' ,
'LN' as 'universalServiceId/codingSystem',
LNUM as 'universalServiceId/altId',
SNAME as 'universalServiceId/altName'
FROM lcodes
WHERE lnum = '14629-0'
FOR XML PATH ('orderedTest'), ROOT('TestData')
-------------------------------



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