本帖最后由 victoryboss 于 2012-12-18 10:43:19 编辑

解决方案 »

  1.   

    可以建立一個回收表.
    --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的數據.
      

  2.   

    在表中多加一列:isdelete,当0时为不删除,1时为逻辑删除,当第一次放到回收站时,改成1.平时查询的时候也加上个where isdelete的条件。当在回收站删除时,才彻底删除这条数据。
      

  3.   

    估计我没说清楚,不过知道怎么做了,谢谢大家哦!!!貌似建立回收表的方式可以哦,不过很麻烦诶,数据量大了库不就爆满了,
    那样得先插入回收表,再删除主表,恢复的时候再插回主表,彻底清空的时候删除回收表四楼高见,平时删除或者恢复只是更改isdelete字段,彻底删除回收站时在delete一下下