Solved

Copying tables between databases.

Posted on 1998-12-14
4
188 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
  • 2
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
cognition earned 40 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

827 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