(Quickly) Delete records from a table, with condition

  • You can use your initial DELETE, perhaps looping it as well:

    DELETE TOP (50000) FROM

    WHERE DATE BETWEEN X AND Y;

    You'd be better off clustering

    on date, if that's it's most often accessed.  It does not need to be a PK, just a clustering index.  You can add an identifier to make it unique if you prefer, and that would prevent ghost rows from remaining in the table.

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

Viewing post 16 (of 15 total)

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