0

how to fetch the data from one database table on another server and insert in to another database table sitting on a different server....I can't to do this.Is it possible using SQL statement or do I need a tool?

Michael Peyper
  • 6,814
  • 2
  • 27
  • 44
Ntando
  • 29
  • 1
  • 7
  • You can do this, have you looked into [Linked Servers](https://learn.microsoft.com/en-us/sql/relational-databases/linked-servers/linked-servers-database-engine)? – Jacob H May 24 '17 at 12:26
  • No will the allow me to get all table rows and some of the columns? – Ntando May 24 '17 at 12:28
  • Yes, it will allow you to run almost any query between the SQL servers. – Jacob H May 24 '17 at 12:29
  • 1
    If it is a once off you could use https://learn.microsoft.com/en-us/sql/integration-services/import-export-data/welcome-to-sql-server-import-and-export-wizard otherwise if you need to run sql queries use linked Servers as Jacob said – Anthony May 24 '17 at 12:30

1 Answers1

0

You could create a linked server on the instance that you are importing data into. You will need to link the server that you are exporting data from. Here are a couple of links on how to set that up.

How to Create a Linked Server

StackOverflow Answer

Calling Linked Server In Query

Once you have the linked server set up, you could do this:

INSERT INTO yourtable --table you are importing data into
SELECT *
FROM [server].[database].[schema].[table] --server you are exporting data from
Jason
  • 945
  • 1
  • 9
  • 17