Reputation: 8839
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#..
Upvotes: 0
Views: 2341
Reputation: 13965
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:
Upvotes: 2
Reputation: 533
I hope the below information will help you: Using SQL Server Management Tools you can use the Import Feature.
Upvotes: 1