Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Copying tables between databases.

Posted on 1998-12-14
4
Medium Priority
?
203 Views
Last Modified: 2010-03-19
Using Transact-SQL.
I've two databases with some identical tables. I want to copy a table from one DB to another as follows.
INSERT Database2.tableX SELECT * from Database1.tableY
Can someone give me the correct syntax of the above ?
0
Comment
Question by:eryan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
cognition earned 160 total points
ID: 1092265
SELECT *
INTO DB2.dbo.ATable
FROM DB1.dbo.ATable

or

SELECT *
INTO DB2.dbo.ATable
FROM ATable


0
 

Author Comment

by:eryan
ID: 1092266
Thanks
0
 
LVL 3

Expert Comment

by:cognition
ID: 1092267
You may even be able to use
DB1..Table, rather than DB1.dbo.Table
0
 

Author Comment

by:eryan
ID: 1092268
Cheers, That works as well.
Ed.
0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question