sqlserver2008跨数据库事务测试

来源:这里教程网 时间:2026-03-02 11:51:13 作者:

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;beginbegin trybegin 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 trybegin catchrollback transaction;--回滚事务print '回滚事务!';end catch;end; 由此可以看出sqlserver目前不支持跨异架构数据库的事务。

相关推荐

热文推荐