[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

copy between databases on different servers

Posted on 2005-04-20
5
Medium Priority
?
801 Views
Last Modified: 2012-08-13
Is there a quick way to copy data from on database to another database on a different server.

No import/export but a command something like select ..... from ....

Thanks
0
Comment
Question by:dgb
5 Comments
 
LVL 21

Accepted Solution

by:
Kevin3NF earned 1500 total points
ID: 13824053
Sure...set up a linked Server definition (see Linked Servers in Books Online)

So from Server A, lets say you want to to pull all the records from a table on ServerB to Server A.


Insert ServerA.MyTable
Select *
From [ServerB].[MyDatabase]..[MyTable] AS MyTableB


0
 
LVL 5

Expert Comment

by:obahat
ID: 13824056
Yes. Define a linked server between the data target server to the data source server: On Enterprise Manager --> Security --> Linked Servers --> Create new.

Set the data source to be OLE DB provider for MS-SQL server.
Set the product name (doesn't really matter much), the data source should be the name of the data source server, and the catalog should be the data source database name.

On security - type the appropriate logins (e.g., if you're an sa, set LocalLogin = sa, and check the impersonate checkmark).
Also check the bullet "Be made ysing the login's current security context".

Finally, on the server options - check the data access, RPC, RPC out and USE REMOTE COLLATION.

Save the new linked server.

For the sake of example, lets assume that the linked server name is <LS>.

The data target machine can now run the query:

SELECT * FROM <LS>.<DataSourceDBName>.dbo.<TableName> and access the data of the data source table.

Hope this helps.

Omri.
0
 
LVL 14

Expert Comment

by:Thandava Vallepalli
ID: 13824166
try with openrowset method....


USE pubs

SELECT a.* INTO MYTABLE
FROM OPENROWSET('SQLOLEDB','DB_SERVER_IPADDRESS';'DB_USER';'PWD',
   'SELECT * FROM pubs.dbo.authors ORDER BY au_lname, au_fname') AS a

itsvtk
0
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13824178
Quick way to add a linked server

exec sp_addlinkedserver @server = N'<SOMELINKSERVERALIAS>',
    @srvproduct = N' ',
    @provider = N'SQLOLEDB',
    @datasrc = N'<DATASBASENAMEOFWHERELINKING>',
    @catalog = N'<CATELOGNAMEOFWHERELINKING>'
GO
0
 
LVL 14

Expert Comment

by:Thandava Vallepalli
ID: 13824194
Examples
A. Use OPENROWSET with a SELECT and the Microsoft OLE DB Provider for SQL Server
This example uses the Microsoft OLE DB Provider for SQL Server to access the authors table in the pubs database on a remote server named seattle1. The provider is initialized from the datasource, user_id, and password, and a SELECT is used to define the row set returned.

USE pubs
GO
SELECT a.*
FROM OPENROWSET('SQLOLEDB','seattle1';'manager';'MyPass',
   'SELECT * FROM pubs.dbo.authors ORDER BY au_lname, au_fname') AS a
GO

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_oa-oz_78z8.asp

itsvtk
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question