共用方式為


Server.AttachDatabase 方法

包含保護的成員
包含繼承的成員

Attaches an existing database that is made up of one or more files to the instance of SQL Server. 

此成員已超載。如需此成員完整的詳細資訊 (包括語法、使用狀況及範例),按一下多載清單中的名稱。

多載 清單

  名稱 說明
公用方法 AttachDatabase(String, StringCollection) Attaches an existing database that is made up of one or more files to the instance of SQL Server with the specified name and using the specified data files. 
公用方法 AttachDatabase(String, StringCollection, AttachOptions) Attaches an existing database that is made up of one or more files to the instance of SQL Server that has the specified name and using the specified data files and attachment options. 
公用方法 AttachDatabase(String, StringCollection, String) Attaches an existing database that is made up of one or more files to the instance of SQL Server with the specified name and using the specified data files. 
公用方法 AttachDatabase(String, StringCollection, String, AttachOptions) Attaches an existing database that is made up of one or more files to the instance of SQL Server by using the specified name, data files, and attachment options. 

上層

備註

The data and transaction log files of a database can be detached and then reattached to the same or another instance of SQL Server. Detaching and attaching a database is useful if you want to change the database to a different instance of SQL Server on the same computer, or if you want to move the database.

請參閱

參考

Server 類別

Microsoft.SqlServer.Management.Smo 命名空間