34,575
社区成员
发帖
与我相关
我的任务
分享
--e.g.
If object_id('tbA')is null
Begin
Create table tbA (ID uniqueidentifier,value nvarchar(50))
Insert into tbA Values(newid(),N'this is test!')
Insert into tbA Values(newid(),N'this is test,too!')
End
If object_id('tbA_ARV')is null
Select *,Convert(datetime,null) As Date Into tbA_ARV From tbA Where 1=2
Delete
From tbA
Output Deleted.*,Getdate()
Into tbA_ARV
Insert into tbA(ID,value)
Select ID,Value from tbA_ARV
Delete From tbA_ARV
Where ID in(Select ID from tbA)
把刪除的數據添加在tbA_ARV表,如果你需要恢復刪除的數據時,就可以從tbA_ARV表中抽取相關的數據并添加在tbA,然後在刪除已添加到tbA的數據.