This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.
The AttachDBWithSingleFile method makes a database visible to an instance of Microsoft SQL Server.
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.
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.