首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

从其他服务器的表里导数据的有关问题

2012-04-24 
从其他服务器的表里导数据的问题。insert into dbo.td_Accept_Errata(SDate, EntRegNO, EntName, RemoveDep

从其他服务器的表里导数据的问题。
insert into dbo.td_Accept_Errata

SDate, EntRegNO, EntName, RemoveDept, Reason, 
OperateMan, RecordID, EntID, cCodeBar, RemoveMan, RemovePhone, SMan, SMode, SReason, SState, 
OperateDate, PassMan, IsValid, IsDW
)
select top 10 
Sdtate, EntRegID, EntName, DeptCode=(select code from codedb..tcdept a where removedeptcode=a.deptname), Reason, 
PassMan,replace(newid(),'-',''),myentid,'','$admin$','','','1','历史数据导入:同意勘误','5',
Sdtate,'$admin$','1','0'
from dbo.Sheet2$ 

两个表导数据。Sheet2$ 里的myentid 如果有的话应该怎么从服务器A的库B的表mytable的里entid获得?
查询的条件是td_Accept_Errata.recordid=mytable.recordid


SQL语句应该怎么写,谢谢。

跨服务器导数据的问题,网上找的方法没解决。这个问题困扰我好几天了。

[解决办法]

SQL code
SELECT AA,isnull((Select EID From OPENDATASOURCE(         'SQLOLEDB',         'Data Source=YC-ZXL\ZHANG;User ID=sa;Password=sa'         ).exam.dbo.course WHERE UID=BB),'sdfsdf') BB FROM TTTGOinsert into dbo.td_Accept_Errata( SDate, EntRegNO, EntName, RemoveDept, Reason, OperateMan, RecordID, EntID, cCodeBar, RemoveMan, RemovePhone, SMan, SMode, SReason, SState, OperateDate, PassMan, IsValid, IsDW)select top 10 Sdtate, EntRegID, EntName, DeptCode=(select code from codedb..tcdept a where removedeptcode=a.deptname), Reason, PassMan,replace(newid(),'-',''),isnull(Select entid From OPENDATASOURCE(         'SQLOLEDB',         'Data Source=服务器A;User ID=sa;Password=sa'         ).库B.dbo.mytable my where dbo.Sheet2$.recordid=my.recordid        ,myentid),'','$admin$','','','1','历史数据导入:同意勘误','5',Sdtate,'$admin$','1','0'from dbo.Sheet2$ 

热点排行