#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    1
    Rep Power
    0

    Help with traversing a HUGE table


    First I apologize if this is a basic question. This is all fairly new to me.

    I am attempting to extract data from a table with 6 million plus records. With each record I qury several other tables and then submit to a new table. It works great when I select the top record. My problem is that I need to traverse the entire table.

    I use cursors in other parts of the script but think that trying to use a cursor on a 6 million record table is a little stupid.

    Does anyone have some advice on a different way?

    Thanks in advance!

    SGlauner
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    7
    Rep Power
    0
    If you have'nt already check out these and some other links on www.sql-server-performance.com - its quite helpful.

    http://sql-server-performance.com/cursors.asp
    http://sql-server-performance.com/transact_sql.asp

    In most cases you should try to avoid using cursor - try replacing it with a set based operation.

    I'd suggest before you submit to the new table, make sure you drop the indexes before your inserts/updates and recreate them at the end - that way you save SQL server the overhead to check referential integrity constraints.

IMN logo majestic logo threadwatch logo seochat tools logo