现在的位置: 首页 > 综合 > 正文

sql server 网络间数据通讯

2012年09月06日 ⁄ 综合 ⁄ 共 495字 ⁄ 字号 评论关闭

  a的ip是:192.168.0.1  
  b的ip是:192.168.0.2   
  a中的一个数据库为testA,表tableA 用户:sa, 密码:sa,123456

  b中的一个数据库为testB,表tableB 用户:sa, 密码:sa,123  
  
  现在要把tableB中的数据导出到tableA   
  insert into testA.dbo.db
  select * from openrowset('sqloledb','192.168.0.2';'sa';'123',testB.dbo.testB)  

  如果只导入id差异的数据:

  insert into testA.dbo.db (userId,userName,userPhoto)

  select userId,userName,userPhoto from openrowset('sqloledb','192.168.0.2';'sa';'123',testB.dbo.testB)
  where userId not in (
      select userId from testA.dbo.testA
  )  
  导入操作是要在b端执行!!!

  注意标点!!!

抱歉!评论已关闭.