• sqlblue (1/5/2009)


    Can I do batch insert or update with a set of rows at a time(does not have to be in order of any kind), and have it automatically go to the next set of rows that have not been inserted or updated? If so, how can I do it?

    thanks for any help.

    Below is my script. The insert is for several millions records, and so I

    break it down by filenumber but it is still big for insert,

    so I try to do it in a small set.

    insert into table2 (col1, col2, col3)

    select table1.col1, table1.col2, table3.col3

    from table1 inner join table3

    on table1.col1 = table3.col1

    where table1.filenumber = 1

    go

    insert into table2 (col1, col2, col3)

    select table1.col1, table1.col2, table3.col3

    from table1 inner join table3

    on table1.col1 = table3.col1

    where table1.filenumber = 2

    go

    yes you can do batched inserts like that... just make sure you have enough log space...

    If table2 (destination) is empty you may want to do all at once using SELECT INTO ... which will be minimally logged.


    * Noel