Home >Database >Mysql Tutorial >mssql 存储过程事务处理与事务隔离级别

mssql 存储过程事务处理与事务隔离级别

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 17:47:34852browse

事务:当一次处理中存在多个操作,要么全部操作,要么全部不操作,操作失败一个,其他的就全部要撤销,不管其他的是否执行成功,这时就需要用到事务.

mssql  事务处理与事务隔离级别

事务:当一次处理中存在多个操作,要么全部操作,要么全部不操作,操作失败一个,其他的就全部要撤销,不管其他的是否执行成功,这时就需要用到事务.

begin tran
update tablea
set columnsa=1,columnsb=2
where recis=1
if(@@error 0 or @@rowcount 1)
begin
rollback tran
raiserror( '此次update表tablea出错!!' , 16 , 1 )
return
end

insert into tableb (columnsa,columnsb) values (1,2)
if(@@error 0 or @@rowcount 1)
begin
rollback tran
raiserror( '此次update表tablea出错!!' , 16 , 1 )
return
end

end
commit

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:sql多表联查实例Next article:sql月份汇总查询语句