小弟想问一下.在192.168.1.2的数据库中.用查询分析.select 表 from 数据库 where id='aaaa' 查到的一个数据为. 0xFFFFFFFFFFFFFFFFFFFFFFFFFFF(2进制数据,是2进制的哦)那么有没办法.直接把查询的数据.写到192.168.1.3的表中呢?
SELECT * FROM OPENDATASOURCE( 'SQLOLEDB', 'Data Source=远程ip;User ID=sa;Password=密码' ).库名.dbo.表名 WHERE 条件 --启用Ad Hoc Distributed Queries: exec sp_configure 'show advanced options',1 reconfigure exec sp_configure 'Ad Hoc Distributed Queries',1 reconfigure --使用完成后,关闭Ad Hoc Distributed Queries: exec sp_configure 'Ad Hoc Distributed Queries',0 reconfigure exec sp_configure 'show advanced options',0 reconfigure select * from OPENDATASOURCE('SQLOLEDB','Data Source=127.0.0.1;User ID=sa;Password=sa').数据库.dbo.表
你可以在192.168.1.3上建立到192.168.1.2的链接服务器,然后在192.168.1.3执行insert into table1 select * from 链接服务器名.数据库名.架构名.表名
在 192.168.1.3建一个192.168.1.2的链接服务器[192.168.1.2] 在 192.168.1.2建一个192.168.1.3的链接服务器[192.168.1.3] 在192.168.1.3的数据库内建一个存储过程[1.2_move_1.3]insert into 1.3上的表 select * from openquery([192.168.1.2],'select * from 1.2上的表') where 条件在192.168.1.2上的存储过程中调用[1.2_move_1.3] exec('1.3数据库.dbo.[1.2_move_1.3]')at [192.168.1.3]至于在哪一步调用就看你的逻辑怎么写了。
远程写入 跟 读取至本地写入那速度不太一样! 远程写入比读到本地写入慢的多
所以建立linkserver的时候别把方向弄反了!方法有linkserver,ssis,openrowset
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
--使用完成后,关闭Ad Hoc Distributed Queries:
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure select * from OPENDATASOURCE('SQLOLEDB','Data Source=127.0.0.1;User ID=sa;Password=sa').数据库.dbo.表
在 192.168.1.2建一个192.168.1.3的链接服务器[192.168.1.3]
在192.168.1.3的数据库内建一个存储过程[1.2_move_1.3]insert into 1.3上的表
select * from openquery([192.168.1.2],'select * from 1.2上的表')
where 条件在192.168.1.2上的存储过程中调用[1.2_move_1.3]
exec('1.3数据库.dbo.[1.2_move_1.3]')at [192.168.1.3]至于在哪一步调用就看你的逻辑怎么写了。