Anda dapat menggunakan beberapa pengetahuan internal tentang bagaimana SQL Server mengimplementasikan XML shredding dan menggunakan row_number()
seperti ini.
declare @XML xml =
'<Rows>
<Row>Coating</Row>
<Row>Drying</Row>
<Row>Waxing</Row>
</Rows>'
select T.X.value('text()[1]', 'nvarchar(100)') as RowLabel,
row_number() over(order by T.X) as RowNumber
from @XML.nodes('/Rows/Row') as T(X)
Ref:Identifikasi Unik Node XML dengan DENSE_RANK
Atau Anda dapat "bermain aman" dan menggunakan tabel angka.
select T.X.value('text()[1]', 'nvarchar(100)') as RowLabel,
N.Number as RowNumber
from Numbers as N
cross apply @XML.nodes('/Rows/Row[sql:column("N.Number")]') as T(X)
where N.Number between 1 and @XML.value('count(/Rows/Row)', 'int')