Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Copy tables

Author  Topic 

joelseverich
Starting Member

34 Posts

Posted - 2009-05-12 : 14:48:35
hi
is there a way to copy table from one db to another including table data

Skorch
Constraint Violating Yak Guru

300 Posts

Posted - 2009-05-12 : 15:07:31
You can script your original table as CREATE (right click on the table in Management Studio, Script Table as -> CREATE TO -> New Window)

Then edit the table name within the script to your new desired table name.

After that just do something like...

INSERT YourNewTable
SELECT * FROM YourOldTable

Some days you're the dog, and some days you're the fire hydrant.
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-05-12 : 23:37:36
select * into reuiredtablename from databasename.schema.tablename
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2009-05-13 : 11:41:45
You can also use the Import or Export functionality in Management Studio: Right-Click on the database in the Object Explorer window and select Tasks -> Export Data (or Import Data depending) and a wizard will walk you through the process.

But, if you want to include the Indexes and such you'll have to use a different tool or script them out.
Go to Top of Page
   

- Advertisement -