次の方法で共有


AttachDBWithSingleFile Method

この機能は、将来のバージョンの Microsoft SQL Server では削除される予定です。新規の開発作業ではこの機能を使用しないようにし、現在この機能を使用しているアプリケーションは修正することを検討してください。

The AttachDBWithSingleFile method makes a database visible to an instance of Microsoft SQL Server.

構文

object
.AttachDBWithSingleFile(
DBName
,
DataFile
)
as String

Parts

  • object
    Expression that evaluates to an object in the Applies To list.
  • DBName
    String that specifies an existing database by name.
  • DataFile
    String that specifies the database PRIMARY data file by operating system (OS) file name.

Returns

A string indicating success or failure

Prototype (C/C++)

HRESULT AttachDBWithSingleFile(SQLDMO_LPCSTR DBName,
SQLDMO_LPCSTR DataFile,
SQLDMO_LPBSTR pResult);

解説

The AttachDBWithSingleFile method is used when a change to the location of OS files implementing the database must be made visible to an instance of SQL Server.

The DataFile argument specifies a single operating system data file implementing storage for a SQL Server database. The instance of SQL Server creates an OS file for transaction log record maintenance as part of the AttachDBWithSingleFile method processing.

ms140734.note(ja-jp,SQL.90).gif重要 :
The AttachDBWithSingleFile method only succeeds when storage for a database is implemented within a single operating system file. A file or files implementing storage for database transaction log records are not made visible by the method. For more information about making multifile databases visible to an instance of SQL Server, see AttachDB Method.

Making a database visible to an instance of SQL Server by using the AttachDBWithSingleFile method requires appropriate permissions. The SQL Server login used for SQLServer object connection must be a member of the system-defined role sysadmin.