copy between databases on different servers

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
dgbAsked:
Who is Participating?
 
Kevin HillSr. SQL Server DBACommented:
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
 
obahatCommented:
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
 
Thandava VallepalliCommented:
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
 
mikelittlewoodCommented:
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
 
Thandava VallepalliCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.