ITPub博客

首页 > 数据库 > SQL Server > sqlserver2008跨数据库事务测试

sqlserver2008跨数据库事务测试

原创 SQL Server 作者:apollotgl 时间:2019-12-27 16:56:34 0 删除 编辑

1.在mysql中建立tp_test1表:

create table tp_test1(

tid int primary key not null,

tgrade int unique key not null

)

2.在sqlserver2008数据库中如下代码:

declare @tgrade int;

set @tgrade=3;

begin

begin try

begin transaction---开启事务

insert openquery(cs_guoquanwang_c,'select tgrade from tp_test1') select @tgrade;--向myssql库插入数据

insert into tp_test1 values(cast(getdate() as varchar(30))+'测试跨数据库事务');--向本机服务器插入数据

commit transaction;--提交事务

end try

begin catch

rollback transaction;--回滚事务

print '回滚事务!';

end catch;

end;


由此可以看出sqlserver目前不支持跨异架构数据库的事务。


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69926160/viewspace-2670980/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2019-06-03

  • 博文量
    2
  • 访问量
    1252