I was looking for an example how to use sql:variable and iterate through it with an indexer.. I never found one and I thank this for giving me the idea. This is my code how i iterated through an xml doc
DECLARE @i TINYINT
SET @i = 0
WHILE @i < @NumberOfBatchFiles
BEGIN
SET @i = @i + 1
SELECT
x.value('Table[1]', 'NVARCHAR(20)') AS TableName,
x.value('File[1]', 'NVARCHAR(100)') AS BatchFile,
x.value('Fields[1]', 'NVARCHAR(50)') AS Fields
FROM
@Xml.nodes('/BatchControlFile/ImportList/ImportFile[position()=sql:variable("@i")]') e(x)
END
Thanks and more power to this site