dgb
asked on
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
No import/export but a command something like select ..... from ....
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
try with openrowset method....
USE pubs
SELECT a.* INTO MYTABLE
FROM OPENROWSET('SQLOLEDB','DB_ SERVER_IPA DDRESS';'D B_USER';'P WD',
'SELECT * FROM pubs.dbo.authors ORDER BY au_lname, au_fname') AS a
itsvtk
USE pubs
SELECT a.* INTO MYTABLE
FROM OPENROWSET('SQLOLEDB','DB_
'SELECT * FROM pubs.dbo.authors ORDER BY au_lname, au_fname') AS a
itsvtk
Quick way to add a linked server
exec sp_addlinkedserver @server = N'<SOMELINKSERVERALIAS>',
@srvproduct = N' ',
@provider = N'SQLOLEDB',
@datasrc = N'<DATASBASENAMEOFWHERELIN KING>',
@catalog = N'<CATELOGNAMEOFWHERELINKI NG>'
GO
exec sp_addlinkedserver @server = N'<SOMELINKSERVERALIAS>',
@srvproduct = N' ',
@provider = N'SQLOLEDB',
@datasrc = N'<DATASBASENAMEOFWHERELIN
@catalog = N'<CATELOGNAMEOFWHERELINKI
GO
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','sea ttle1';'ma nager';'My Pass',
'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
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','sea
'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
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>.db
Hope this helps.
Omri.