Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 206
  • Last Modified:

Copying tables between databases.

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
eryan
Asked:
eryan
  • 2
  • 2
1 Solution
 
cognitionCommented:
SELECT *
INTO DB2.dbo.ATable
FROM DB1.dbo.ATable

or

SELECT *
INTO DB2.dbo.ATable
FROM ATable


0
 
eryanAuthor Commented:
Thanks
0
 
cognitionCommented:
You may even be able to use
DB1..Table, rather than DB1.dbo.Table
0
 
eryanAuthor Commented:
Cheers, That works as well.
Ed.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now