Let us consider the a table (shown below) with couple of columns that needs to be exported as XML
The following query
SELECT TOP 1000 [TrainID] as 'TrainNum'
,[TrainName]
FROM [OnlineTrans].[dbo].[TrainMaster] for XML PATH
Is used for generating a XML
On the other hand, If you want to have a meaningfully named element instead of
SELECT TOP 1000 [TrainID] as 'TrainNum'
,[TrainName]
FROM [OnlineTrans].[dbo].[TrainMaster] for XML path ('TrainInfo'), root ('ParentInfo')
No comments:
Post a Comment