Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy Table

Status
Not open for further replies.

NoKeS

Programmer
Sep 27, 2001
21
PT
Hi,
whats the code to copy tables that are in one database to another database??

Databases Name:
FORMACAO3 - SOURCE DATABASE
FORMACAO3AUXILIAR - Destiny Database


URGENT!!!
 
This is potentially quite tricky. One table is easy, either use DTS via the import/export wizard or run an insert into query (qualifying the table with a database prefix). If you have more than one table, and there are relationships, you're in for a bit of work. I suggest scripting the source database, and creating the tables with that. Next use DTS, but transfer the tables in the correct order, being aware of referential integrity. (We actually have a VB program that will handle all this for us). Of course, if you have a lot of tables, is a backup/restore an option, or do you need to preserve data in the destination ? If that's not enough detail, please clarify your situation, and I'll expand on the relevant scenario.
 

If you want to transfer the entire database do the following.

1) Backup the original DB.
2) Restore the backup to the new datbase.

You can do this with Enterprise Manager. If you want to use T-SQL, read the topic "How to restore a database with a new name (Transact-SQL)" in SQL Books Online (BOL).

You can also use DTS. It should handle dependecies properly if you set the proper options. Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top