共用方式為


AttachDatabase 方法

將包含一個或多個檔案的現有資料庫附加至 SQL Server 的執行個體。 

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

多載 清單

  名稱 說明
公用方法 AttachDatabase(String, StringCollection) 使用指定的資料檔並使用指定的名稱,將包含一個或多個檔案的現有資料庫附加至 SQL Server 的執行個體。 
公用方法 AttachDatabase(String, StringCollection, AttachOptions) 將具有指定名稱、使用指定的資料檔和附加選項,且包含一個或多個檔案的現有資料庫附加至 SQL Server 的執行個體。 
公用方法 AttachDatabase(String, StringCollection, String) 使用指定的資料檔並使用指定的名稱,將包含一個或多個檔案的現有資料庫附加至 SQL Server 的執行個體。 
公用方法 AttachDatabase(String, StringCollection, String, AttachOptions) 使用指定的名稱、資料檔和附加選項,將包含一個或多個檔案的現有資料庫附加至 SQL Server 的執行個體。 

上層

備註

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.