SQL Server - Copy a table from one database to another database

SQL Server - Copy a table from one database to another database

Post by spa.. » Sat, 29 Mar 2003 14:52:27



Hi.
I need to keep a copy of a table T along with its data in a Database D1 to another database D2. New table shoould be indentical to old one by copying all primary key and other properties.

Sriparna.

**********************************************************************

Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...

 
 
 

SQL Server - Copy a table from one database to another database

Post by Allan Mitchel » Sat, 29 Mar 2003 16:10:25


Hello, Sriparna!

You can do it a number of ways but here is two

Generate the script (Right Click on table | All Tasks | Generate SQL Script)
Apply script in database 2 and then use either
    a.  A Data Pump
    b  INSERT INTO Database.dbo.Table (Col List) SELECT Col list FROM
dbo.Table

2  Use the transfer SQL Server objects task in DTS.

For the sake of one table though I would go with option 1

--

Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org

: Sriparna.

      ---