0

Have a question. I have two statements as below:

Statement #1

Insert into tblAudit (Col1, Col2)
Select Col1, Col2 From tblSoruce
Where "Same Condition"

Statement #2

Delete from tblSource
Where "Same Condition"

I am trying to first put in an audit table, all the rows that are being deleted later.

What is the best way to accomplish this without "missing" any rows in between the 2 statements?

In the way I have the SQL statements, the number of rows can change from the first to the second statement, which is not what I want. (I can't use the OUTPUT clause as there are FK relationships)

Any help in how to accomplish this in a more efficient manner (without temp tables)

Thanks.

4

1 回答 1

1

当从 tblSource 中删除值时,您可以使用触发器自动执行插入审计日志;这样您就可以确切地知道哪些行被删除并且应该插入到 tblAudit 中。

于 2013-04-30T19:52:20.870 回答