Wouldn't have guessed that was what you wanted and can't think of a reason for it.What happpens after you have created the rid in table2 if theres already a rid of that number in table1?Something likecreate table #a (grid int, rid int)insert #a select t1.Grid, t1.ridfrom table1 t1join table2 t2on t1.rid = t2.ridwhere t1.grid > (select min(grid) from table1 t3 where t3.rid = t2.rid)declare @i int, @id intselect @i = 0while @i < (select max(grid) from #a)begin select @i = min(grid) from #a where grid > @i insert table2 (RText) select RText from Table2 where rid = (select rid from #a where grid = @i) select @id = scope_identity() update table1 set rid = @id where grid = @iend
==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy.