copy data from one server to another using query in import/export wizard?

我怕爱的太早我们不能终老 提交于 2019-12-24 11:18:11

问题


I have one table a in one db server..and table b in another server.

I would like to update the table b using values in table a.

How do I specify the server name in query ?

UPDATE SELECT * from [db1].[dbo].StgMGBPData
   SET ASO_Ind = [db2].[dbo].Customer_Names.ASO_Ind,
       Company = [db2].[dbo].Customer_Names.Company,
       Rpt_Cust_ID = [db2].[dbo].Customer_Names.Rpt_Cust_ID
  FROM [db2].[dbo].Customer_Names
  JOIN [db1].[dbo].StgMGBPData ON [db2].[dbo].Customer_Names.Src_Cust_ID = [db1].[dbo].StgMGBPData.CustomerID

回答1:


Try linked server because without linked server you can't use server name in query.

You can use sp_addlinkedserver. See an example here:

EXEC sp_addlinkedserver
   @server = 'SERVER',-- your servername
   @provider = 'SQLOLEDB',
   @srvproduct = '',
   @datasrc = 'SERVER', -- your servername
   @catalog = 'NHS_032808' 
   -- your database name which you want to connect

Like that exec the procedure with like that parameter after you can fire the query in connected database like below.

select * from SERVER.NHS_032808.dbo.tbl_resident_mst



回答2:


If lack of permissions prevents you from using Linked Server yet you are able to connect to both servers from a client and have the necessary select-permissions on the table in server A and the necessary update/insert permissions on the table in server B, then you could use Micorosoft JET in your client to bridge the servers. Data from server A is pulled out to the client where it is then pushed to server B. This falls under the general category of "heterogeneous joins", which was one of the major strengths of JET in an enterprise (multi-server) scenario. This bridging requires more bandwidth than a Linked Server approach does, but it will get the job done. You would create links in JET to the tables in each server and would thereafter be able to refer to both within the same query.



来源:https://stackoverflow.com/questions/5439596/copy-data-from-one-server-to-another-using-query-in-import-export-wizard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!