Tuesday, March 27, 2012

enumerate the rows of the xml

It is possible to enumerate the rows of the xml in a consultation?
For example:
select cast(tb01_XML as xml)
from Table01 as USU
where ID = 1
for xml raw(''), elements, type
<CAR xmlns="Hello" Name="Ricardo" />
<CAR xmlns="Hello" Name="Ricardo" />
-->
<CAR xmlns="Hello" Num="1" Name="Ricardo" />
<CAR xmlns="Hello" Num="2" Name="Ricardo" />
thank for any help
How exactly does your data look like?
You could use the ROW_NUMBER() function to add an enumeration...
Best regards
Michael
"sqlextreme" <sqlextreme@.discussions.microsoft.com> wrote in message
news:ABFC1DCD-1D33-4DBE-A606-68985452DE31@.microsoft.com...
> It is possible to enumerate the rows of the xml in a consultation?
> For example:
> select cast(tb01_XML as xml)
> from Table01 as USU
> where ID = 1
> for xml raw(''), elements, type
> <CAR xmlns="Hello" Name="Ricardo" />
> <CAR xmlns="Hello" Name="Ricardo" />
> -->
> <CAR xmlns="Hello" Num="1" Name="Ricardo" />
> <CAR xmlns="Hello" Num="2" Name="Ricardo" />
> thank for any help
>

No comments:

Post a Comment