CREATE PROC [dbo].[notice_Delete] --- 同时删除该通知书和对应的节点 @tbl VARCHAR(30), @pid INT AS BEGIN DECLARE @tblname VARCHAR(30) ; DECLARE @sql VARCHAR(1000) ; SET @tblname = @tbl SET @sql = 'delete ' + @tblname + ' where id =' + CONVERT(VARCHAR(10), @pid) BEGIN TRAN --开始事务 EXEC ( @sql ) IF ( @@rowcount = 0 ) --执行结果影响行数为0 BEGIN ROLLBACK TRAN --回滚 END ELSE BEGIN DELETE FROM tbl_treenotice WHERE purposeid = @pid IF ( @@rowcount = 0 ) --执行结果影响行数为0 BEGIN ROLLBACK TRAN --回滚 END ELSE BEGIN COMMIT TRAN --提交事务 END END END