两个表a ,b .
我点界面上的按钮,然后清空ab两表的所有数据。
我感觉应该运行truncate table a  和 tuncate table b然后想是不是该用一个触发器来完成。
求解。

解决方案 »

  1.   

    create procedure p1
    as
    begin
    begin tran
    truncate table a
    truncate table b
    commit 
    end
    go
      

  2.   

    DECLARE @ERR INT
    SET @ERR=0
    BEGIN TRAN
     truncate table a
     SET @ERR=@ERR+ABS(@@ERROR)       
     truncate table b
     SET @ERR=@ERR+ABS(@@ERROR)   
    IF @ERR=0
      COMMIT
    ELSE
      ROLLBACK 
      

  3.   


    create procedure truncate_table
    as
    begin
        begin tran
            truncate table a
            truncate table b
        commit 
    end
    go