最初由 Rationalist 发布
1. The second fastest method for whole databases is to use the DUMP DATABASE and
LOAD DATABASE commands. You need to make sure that the databases are the
same size and made up of the same segment fragments in the same order. If
you do an sp_help_revdatabase on both this will allow you to check the
required DDL for this. You can DUMP and LOAD from a local tape device and
transport the tape if you do not have a network connection. (With SQL
7.0/2000 the commands are BACKUP DATABASE and RESTORE DATABASE). You may have
the same problem as Itme 0 with different database version.
2. If you only want tables/data you can use the SQL BCP.EXE tool. This is
a command-line program and is fully documented in the books-online. It
works on one table at a time and allows you to create a flat file on disk.
3. For stored-procedures/views etc. there is an old command-line based tool
called DEFNCOPY.EXE that works like BCP.
4. SQL Enterprise Manager comes with a built-in GUI transfer function.
This allows transfer of all objects between two databases/servers but
requires a network connection between the two.
5. The transfer tool supplied with SQL Enterprise Manager is exposed via
the DMO interface and can be called using the SQLOLE calls from TSQL or your
own VB program for automation purposes.
6. For SQL 7.0 and above the obvious choice is to use Data Transformation
Services. You can transfer and data by simply using the Import/Export Wiazrd
to build a package based on the DataPump/Transform Data Task. The
TransferObjects task can be used to move all objects as well as tables, and
supports the transfer of keys, indexes and pemissions as well as just data.
In SQL 2000 there is also the Transfer Database Task which greatly
simplifies the task of transferring an entire database.
7. 3rd-party DBMS management tools no doubt offer similar/better
transfer/scripting tools to the above.