TransferSQLDatabase Method
Transfers the entire specified Microsoft SQL Server database to another SQL Server database.
expression.TransferSQLDatabase(Server, Database, UseTrustedConnection, Login, Password, TransferCopyData)
expression Required. An expression that returns a DoCmd object.
Server Required Variant. The name of the SQL Server to which the database will be transferred.
Database Required Variant. The name of the new database on the specified server.
UseTrustedConnection Optional Variant. True if the current connection is using a login with system administrator privileges. If this argument is not True, you must specify a login and password in the Login and Password arguments.
Login Optional Variant. The name of a login on the destination server with system administrator privileges. If UseTrustedConnection is True, this argument is ignored.
Password Optional Variant. The password for the login specified in Login. If UseTrustedConnection is True, this argument is ignored.
TransferCopyData Optional Variant. True if all data in the database is transferred to the destination database. If this argument is not True, only the database schema will be transferred.
Remarks
The following conditions must be met or else an error occurs:
-
The current and destination servers are SQL Server version 7.0 or later.
-
The user has system administrator login rights on the destination server.
-
The destination database doesn't already exist on the destination server.
Example
This example transfers the current SQL Server database to a new SQL Server database called Inventory on the server MainOffice. (It is assumed that the user has system administrator privileges on MainOffice.) The data is copied along with the database schema.
DoCmd.TransferCompleteSQLDatabase _
Server:="MainOffice", _
Database:="Inventory", _
UseTrustedConnection:=True, _
TransferCopyData:=False