触发器 存储过程 事务 模板

来源:互联网 发布:服装跟单软件 编辑:程序博客网 时间:2024/04/29 09:14

--------------------触发器开始----------------------------------------

create trigger update_tablename
on tablename --要触发的表名
for update    --要触发的类型
as
begin
-----触发操作体
end

--------------------触发器结束    存储过程开始----------------------------------------


create procedure   ds_procedurename --存储过程名
as
begin

end

-------------------- 存储过程结束 事务开始----------------------------------------

begin transaction -----------------------------开始事务

declare @errors int ------------------------------定义错误计数器
set @errors=0    ------------------------------------没错为0

set @errors=@errors+@@error
if @errors<>0
        begin print 'error' rollback transaction end --事务回滚语句
else 
         begin print 'success' commit transaction end --事务提交语句

end

0 0
原创粉丝点击