哪们大虾能给一个ROLLBACK TRANSACTION的存储过程实例,谢谢了,我是小鸟谢谢老师
哪们大虾能给一个ROLLBACK TRANSACTION的存储过程实例,谢谢了,我是小鸟谢谢老师,如果比较复杂最好写上注释,谢谢!
------解决方案--------------------ROLLBACK TRANSACTION 这个就是回滚事务
BEGIN TRANSCTION
多个语句
IF @error = 0
COMMIT
ELSE
ROLLBACK TRANSACTION
不论是提交事务还是回滚事务,这个事务都结束
------解决方案--------------------BEGIN
SET NOCOUNT ON;
BEGIN TRY
BEGIN TRANSACTION;
---here input your batch commmands(do not make the transaction too big[not recommended] )
COMMIT TRANSACTION;
END TRY
BEGIN CATCH
-- Rollback any active or uncommittable transactions before
IF @@TRANCOUNT > 0
BEGIN
ROLLBACK TRANSACTION;
END
END CATCH;
END;