可以建立一個回收表. --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!') EndIf object_id('tbA_ARV')is null Select *,Convert(datetime,null) As Date Into tbA_ARV From tbA Where 1=2Delete From tbA Output Deleted.*,Getdate() Into tbA_ARVInsert into tbA(ID,value) Select ID,Value from tbA_ARVDelete From tbA_ARV Where ID in(Select ID from tbA)
--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!')
EndIf object_id('tbA_ARV')is null
Select *,Convert(datetime,null) As Date Into tbA_ARV From tbA Where 1=2Delete
From tbA
Output Deleted.*,Getdate()
Into tbA_ARVInsert into tbA(ID,value)
Select ID,Value from tbA_ARVDelete From tbA_ARV
Where ID in(Select ID from tbA)
把刪除的數據添加在tbA_ARV表,如果你需要恢復刪除的數據時,就可以從tbA_ARV表中抽取相關的數據并添加在tbA,然後在刪除已添加到tbA的數據.
那样得先插入回收表,再删除主表,恢复的时候再插回主表,彻底清空的时候删除回收表四楼高见,平时删除或者恢复只是更改isdelete字段,彻底删除回收站时在delete一下下