Any time you prepare to delete data from a database, you will probably wonder whether or not to log the deleted data somewhere… just in case.
One way to do this is to construct a SELECT
statement to identify the rows you want to delete, and then use it to copy those rows into a separate log table, before doing the actual delete. If you’re using SQL Server, another option is to use the OUTPUT
clause. This article discusses the later.