复制代码 代码如下:
begin try
begin transaction
insert into shiwu (asd) values ('aasdasda');
commit transaction
end try
begin catch
select ERROR_NUMBER() as errornumber
rollback transaction
end catch
复制代码 代码如下:
set implicit_transactions on; -- 启动隐式事务
go
begin try
insert into shiwu (asd) values ('aasdasda');
insert into shiwu (asd) values ('aasdasda');
commit transaction;
end try
begin catch
select ERROR_NUMBER() as errornumber
rollback transaction; --回滚事务
end catch
set implicit_transactions off; --关闭隐式事务
go
复制代码 代码如下:
alter database;
backup;
create database;
drop database;
reconfigure;
restore;
update statistics;
复制代码 代码如下:
--创建存储过程
create procedure qiantaoProc
@asd nchar(10)
as
begin
begin try
begin transaction innerTrans
save transaction savepoint --创建事务保存点
insert into shiwu (asd) values (@asd);
commit transaction innerTrans
end try
begin catch
rollback transaction savepoint --回滚到保存点
commit transaction innerTrans
end catch
end
go
begin transaction outrans
exec qiantaoProc 'asdasd';
rollback transaction outrans
新闻热点
疑难解答