How to select query as XML format?
I had my query to select the fields in xml . what i need is to display the
xml not in one line as .
<AllPlayers><Player><fbid>1236598</fbid><fbname>joan</fbname><fbscore>99999999</fbscore></Player><Player><fbid>55559999888</fbid><fbname>smith</fbname><fbscore>99999999</fbscore></Player></AllPlayers>
but as :
<AllPlayers>
<Player>
<fbid>1236598</fbid>
<fbname>Mohamed Hamam</fbname>
<fbscore>99999999</fbscore>
</Player>
<Player>
<fbid>55559999888</fbid>
<fbname>mostafaa Hamam</fbname>
<fbscore>99999999</fbscore>
</Player>
</AllPlayers>
my query :
ALTER PROCEDURE [dbo].[procGetPlayerScore]
AS BEGIN
SELECT DISTINCT TOP (10)
fbid ,
Name as fbname,
Score as fbscore
FROM
dbo.FB_Player
ORDER BY
Score DESC
FOR XML PATH('Player'), ROOT('AllPlayers')
END
No comments:
Post a Comment