0

I have to copy tables from Database 1 at 'x' instance to another database which is empty right now on instance 'y' in SQL Server 2008.

How can I achieve this ?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
RobertD
  • 1
  • 1
  • Welcome to Stack Overflow, @RobertD. More information will probably be helpful in answering your question. For example, what interface to SQL Server 2008 are you using? What have you tries so far? In what way did it fail to work as you expected? – Degan Aug 02 '17 at 21:55
  • What i tried is the task utility which is giving me errors as i have difficulty to find the correct source i need to put. "what interface to SQL Server 2008 are you using?" WHAT DOES THAT mean. Actually i am quite new to sql and by interface i can only imagine of the ssms that i am using – RobertD Aug 02 '17 at 22:08
  • Based on your requirements, you just have to back up database 1 and restore it to instance y – Nick.Mc Aug 02 '17 at 22:14
  • But the database is like millions of records which would take a lot of time. I need to migrate only couple of tables. Any idea how should i achieve it. – RobertD Aug 02 '17 at 22:28

1 Answers1

1

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
  • Thats perfect. Thanks a ton. If i may to ask if i need to not only copy data but copy all the integrity and constraints as well. Example i want to copy tables with all the the primary foreign key and other constraints it has with other tables. I hope i am explaining correctly – RobertD Aug 04 '17 at 00:02