how to minimize tempdb during insert?

  • I am new to sql programming, I need help on insert statement. I need to insert a huge set of data(20 million rows) into a table, and the tempdb keep running out of space(we have about 2000 mb configure for tempdb). The insert statement go like this

    declare @rowupdate int

    set @rowupdate = 1

    set rowcount 10000

    while @rowupdate > 0

    begin

    insert into customers(cus_id,cus_lname, cus_fname, ss#)

    select cus_id,cus_lname, cus_fname, ss# from site a join record b

    on a.docid=b.docid

    @rowupdate=@@rowcount

    end

    go

    is there a way to minimize tempdb growth during insert process?

    Thanks for your help

  • How are you controlling the while flow. I see nothing that would cause rowupdate to become 0 and see no reason for it. DO you get the same tempdb problem just doing the insert itself and is it the tempdb or log file that is the issue?

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply