I would use something similar to Chris' SQL - but I would create #BatchControl manually with a clustered index on the RowID, then use a counting loop similar to gyesql's solution. I'd get the maximum using IDENT_CURRENT though, and not SELECT MAX().
Atlantis Interactive - SQL Server Tools
My blog[/url]
Why I wrote a sql query analyzer clone