Solved: SQL Server - queries between servers

Select from server1.db1.table into server2.db2.table

Page 1 of 1

1 Replies - 5222 Views - Last Post: 13 October 2009 - 01:06 AM Rate Topic: -----

#1 jase81   User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 120
  • Joined: 02-March 09

Solved: SQL Server - queries between servers

Posted 10 October 2009 - 02:21 PM

I have two servers which databases that do not match. I want to copy some records from server1.database1 into a table on server2.database2.

select a, b
from server1.database1.table
into server2.database2.table

Any help would be greatly appreciated.


INSERT INTO destination_table
					  (column1, column2, column3)
SELECT	 column1, column2, column3
FROM		 SENDING_SERVER.database.dbo.table

This post has been edited by jase81: 10 October 2009 - 02:44 PM

Is This A Good Question/Topic? 0
  • +

Replies To: Solved: SQL Server - queries between servers

#2 eralper   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 20-January 07

Re: Solved: SQL Server - queries between servers

Posted 13 October 2009 - 01:06 AM

Hello Jase,

For working with remote computers you should create linked servers and use linked servers in your select queries
Please refer to Create Linked Server for linked server creation script. You can also use the SSMS as a GUI to create linked server.

After creating a linked server in MS SQL Server, please execute the below t-sql query. Note that [ and ] are required around linked server.

select * into remotesystemtables 
from [linkedservername].master.sys.tables

select * from remotesystemtables 

Note that if you create the remotesystemtables before executing the select into statement, your query will fail.
select into will dynamically create a copy of the source table.

I hope this will help you solve your problem
SQL Server & T-SQL programming
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1