• ScottPletcher (11/8/2012)


    It depends. Often it's faster just to keep the desired rows rather than delete all the undesired. That is, copy the good rows to another table, trunc the table, copy the good rows back in.

    Otherwise you can DELETE in batches as Sean suggests ... but don't forget the filter on the DELETE statement itself :-).

    If im only keeping a small number of rows i will insert the rows into a new table but instead of truncating and reinserting the rows i will rename the tables. this will have much less down time as i dont have to reinsert the records into the original table after the truncate. once the tables are renamed i can keep the old table around to make sure every thing is working fine then just drop the table. Personally i think this method has a little more redundancy as the data is never gone until im sure i have every thing i need.


    For faster help in answering any problems Please read How to post data/code on a forum to get the best help - Jeff Moden[/url] for the best way to ask your question.

    For performance Issues see how we like them posted here: How to Post Performance Problems - Gail Shaw[/url]

    Need to Split some strings? Jeff Moden's DelimitedSplit8K[/url]
    Jeff Moden's Cross tab and Pivots Part 1[/url]
    Jeff Moden's Cross tab and Pivots Part 2[/url]