Results 1 to 8 of 8

Thread: mass delete - built for speed - mssql tsql

  1. #1
    Join Date
    May 2005
    Posts
    111

    mass delete - built for speed - mssql tsql

    what is the quickest way to purge the first 15 million rows in a 42 million row table? FYI---there is a row_no and also a date_added column in the table. i could key off a date or the row_no in the query--there is a direct coralation between the first 15 million rows and said columns. -allen

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    By multiple small batches based on those columns.

  3. #3
    Join Date
    May 2005
    Posts
    111

    reply

    should i use a cursor and do 1 row at a time?

  4. #4
    Join Date
    Sep 2002
    Posts
    5,938
    Or try with loop.

  5. #5
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    remember to put the database in simple recovery mode, this will prevent the log file running out of space.

  6. #6
    Join Date
    May 2005
    Posts
    111

    reply

    yep, that was one of the first steps i took. although i didn't restart sql or the agent after said change--assumimg change was dynamic?

  7. #7
    Join Date
    Sep 2007
    Posts
    7

    reply

    copy the current table structure to a new table without indexes. select the records you want to keep into the new table. drop the old table.

  8. #8
    Join Date
    Sep 2002
    Posts
    5,938
    Don't need restart sql after changing recovery mode, change it back once done with deleting rows.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •