跨服务器插入数据
目的就是想把插入到表中的数据同步插入到另一台远程的SQL服务器上,表结构相同,我写的哪里有问题么?
CREATE TRIGGER [nmtohrb] ON [dbo].[recfiles] FOR INSERTASBeginInsert into OPENDATASOURCE('SQLOLEDB','Data Source=www.baidu.com;User ID=sa;Password=XXX').aaa.dbo.recfiles select * from insertedEnd
--加上下面两句,否则会提示新事务不能登记到指定事务处理器set xact_abort on begin distributed tran
[解决办法]
CREATE TRIGGER [nmtohrb] ON [dbo].[recfiles] FOR INSERTASbegin --少了个begin set xact_abort on begin distributed tran Insert into OPENDATASOURCE('SQLOLEDB','Data Source=www.baidu.com;User ID=sa;Password=XXX').aaa.dbo.recfiles select * from insertedEnd