This would be easier to do in SQL, which inserts the XML records into the #tmp table.
Consider the following @recs table, which can be thought of as a set of records generated from XML:
declare @recs table (val varchar(255)) insert into @recs values ('this'), ('is'), ('a'), ('test')
You can easily add an incrementing integer to each record as follows:
select row_number() over (order by (select 1)) as id, val from @recs
The result is as follows:
id val 1 this 2 is 3 a 4 test
Could you use row_number() over (order by (select1)) to generate the identifiers you need at the same time that the records are inserted in #tmp ?
James L.
source share