just do this to retrieve the element count for the loop - we've had to do this a lot..
select @max-2 = @x.value('fn:count(/Employees/Employee)','int')
or you could even include the xpath in the while loop definition:
while @i <= (@x.value('fn:count(/Employees/Employee)','int'))
begin
print @i
set @i = @i + 1
end
there are a lot of fn: xpath functions that work really well for different situations - BOL has a listing of them, just search for "fn:"