Solved

copy a table with data to another db

Posted on 2013-06-25
2
221 Views
Last Modified: 2013-06-25
I have a table1 in database1.  I would like to have all the structure and data copied to database2 with the name table1.

How can I do this in SQL 2008
0
Comment
Question by:al4629740
[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 Comments
 
LVL 66

Assisted Solution

by:Jim Horn
Jim Horn earned 150 total points
ID: 39276616
SELECT *
INTO TargetDatabase.TargetTable
FROM SourceDatabase..SourceTable

Then I'd check the TargetTable to make sure identities are set, constraints are still there, etc.

If that fails, a better way may be to script out the SourceTable, change the database/table name, then execute it in TargetDatabase.

Create Table
Then...

INSERT INTO TargetDatabase.TargetTable
SELECT * FROM SourceDatabase..SourceTable
0
 
LVL 12

Accepted Solution

by:
duttcom earned 350 total points
ID: 39276627
You can also right-click on your source database and choose Tasks -> Export Data.

The wizard then steps you through the selection of the data source and the destination and copies the table for you.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

     When we have to pass multiple rows of data to SQL Server, the developers either have to send one row at a time or come up with other workarounds to meet requirements like using XML to pass data, which is complex and tedious to use. There is a …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

729 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