首页 > 数据库 > SQL Server > sqlserver2008跨数据库事务测试
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/ ,如需转载,请注明出处,否则将追究法律责任。