从其他服务器的表里导数据的问题。
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语句应该怎么写,谢谢。
跨服务器导数据的问题,网上找的方法没解决。这个问题困扰我好几天了。
[解决办法]
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$