copy a table with data to another db

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
al4629740Asked:
Who is Participating?
 
duttcomConnect With a Mentor Commented:
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
 
Jim HornConnect With a Mentor Microsoft SQL Server Developer, Architect, and AuthorCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.