Condividi tramite


AttachDBWithSingleFile2 Method

Questa funzionalità verrà rimossa in una delle prossime versioni di Microsoft SQL Server. Evitare di utilizzare questa funzionalità in un nuovo progetto di sviluppo e prevedere interventi di modifica nelle applicazioni in cui è attualmente implementata.

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

Sintassi

object
.AttachDBWithSingleFile2(
DBName
,
DataFile
)
as Boolean

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 file name.

Prototype (C/C++)

HRESULT AttachDBWithSingleFile2(
SQLDMO_LPCSTR DBName, 
SQLDMO_LPCSTR DataFile, 
LPBOOL pRetVal) PURE;

Osservazioni

The AttachDBWithSingleFile2 method is used when a change to the location of operating system (OS) files implementing the database must be made visible to the instance of SQL Server.

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

The AttachDBWithSingleFile2 method returns TRUE if the attach database operation succeeds. Applications that require detailed information regarding the success or failure of the attach database operation can call the AttachDBWithSingleFile method, which returns a detailed string containing this information.

ms138325.note(it-it,SQL.90).gifImportante:
The AttachDBWithSingleFile2 method only succeeds when storage for a database is implemented within a single operating system file. Files that implement storage for database transaction log records are not made visible by the method. For more information about making multiple databases visible to an instance of SQL Server, see AttachDB Method.

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

[!NOTA] If an application calls AttachDBWithSingleFile2 on an instance of SQL Server version 7.0, the constant SQLDMO_E_SQL80ONLY and a message message similar to "This property or method requires Microsoft SQL Server 2000" are returned.

Applies To:

SQLServer2 Object