How to copy table data from remote server to Local server in SQL Server 2008

对着背影说爱祢 提交于 2019-12-25 09:33:02

问题


I am trying to copy all table data from server to my local database, like

INSERT INTO [.\SQLEXPRESS].[Mydatabase]..MYTable
   SELECT * 
   FROM [www.MYSite.com].[Mydatabase]..MYTable

www.MYSite.com having SQL LOGIN ID XYZ AND PASSWORD 1234

but I get an error:

Could not find server 'www.MYSite.com' in sys.servers.
Verify that the correct server name was specified. If necessary,
execute the stored procedure sp_addlinkedserver to add the server to sys.servers.

I want to copy all the data from Mytable of www.MYSite.com to Mytable of .\SQLExpress.

How to resolve it? Please help.

Update :

I am using Microsoft Sync Framework 2.0 to sync all data from www.MYSite.com to .\SQLExpress and vice versa, but in a one condition I want to copy data from www.MYSite.com to .\SQLExpress without sync framework

Please Note I am passing those SQL Statement using C#..


回答1:


I hope the below information will help you: Using SQL Server Management Tools you can use the Import Feature.

  1. Connect to your SQL instance server.
  2. Select your database schema.
  3. Right click Tasks > Import.
  4. and follow wizard instructions.




回答2:


When you specify a database on another server, like this:

SELECT * 
FROM [www.MYSite.com].[Mydatabase]..MYTable

... the server name needs to be one that the database server was previously configured to recognize. It needs to be in the system table sys.servers.

So, you need to configure your SQLExpress instance to "know about" that server.

You can do this in code, with the stored procedure sp_addlinkedserver. You can learn more about it here.

Or, you can do it through SSMS:



来源:https://stackoverflow.com/questions/26697423/how-to-copy-table-data-from-remote-server-to-local-server-in-sql-server-2008

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