• I would never use a table variable for this -- if something goes wrong after the DELETEs, but before the output has been processed, the data is gone, with no way to get it back.

    Do you have a separate db that you use for export / other utility purposes? If not, you may want to create one. Output the rows to be deleted to a table, then delete the rows.

    Process that other table within a transaction, so that the rows must be successfully exported before the export table has its rows deleted.

    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".