I want to move an existing table from another.
Example
B.mdf dbo.xx toC.mdf dbo.xx
B.mdf dbo.xx has records - I created a script and install the script for C.mdf dbo.xx
C.mdf dbo.xx is empty -
All I need now is to populate the records from B.mdf dbo.xx to the empty C.mdf dbo.xx
I was telling I could do a cut and paste to copy the dbo.xx
Thank you in advance.
~ Peaches ~
With SQL 2000 use DTS to copy to contents. With SQL2005 use SSIS.
There is another way and you don't need to create the target table first:
You can copy database tables from one database to another. Here is a sample for you to move one table from one database to another database without creating the new table first.
Run this from the database you want to export data:
SELECT*INTO newDataBaseName.dbo.yourNewTableFROM tableToExpost
|||Couple of things to keep in mind are:
(1) If you already created the target table with PK-FK relationships, indexes, you can either use DTS or
INSERT INTO TargetDB.dbo.TargetTable (<columns>)
SELECT <columns> FROM SourceDb.dbo.SourceTable
(2) If the target table does not exist, then you can uss limno's approach and do a SELECT * INTO TargetDb.dbo.TargetTable FROM SourceDB.dbo.SourceTable WHERE <Condition>
(3) IF there is lot of data ( as in > few million rows) you might also want to look into BCP utility in Books On Line.
|||Thank you very much !!!!!
I was able to take care of this in 5 minutes ...
Whew::: This makes my life easier today.
~ Peaches ~
No comments:
Post a Comment