• Not needed

    Depending on uniqueness something like

    insert into #table2 (t_col2) select col1 from #table1

    insert into #table3 (f_col3) select t_col1 from #table2 t2 join #table1 t1 on t1.col1 = t2.t_col2

    could work.

    If one would actually need to insert the values one at a time i would use a while instead. Like

    declare @i int

    set @i = 0

    while exists (select * from #table1 where col1 > @i)

    begin

    select top 1 @i = col1 from #table1 where col1 > @i

    insert into #table2 (t_col2) values (@i)

    insert into #table3 (f_col3) values(SCOPE_IDENTITY())

    end

    /T