Attaching a Single-File Database

Creating and Maintaining Databases

Creating and Maintaining Databases

Attaching a Single-File Database

If a database comprises only a single data file and a single transaction log file, the database can be attached to an instance of Microsoft® SQL Server™ 2000 without using the transaction log file, provided the database was cleanly shut down with no users and no open transactions. When the data file is attached, SQL Server creates a new transaction log file automatically.

The database must have been successfully detached from SQL Server using the sp_detach_db system stored procedure.

Single-file databases are useful if you want to e-mail databases to other users. All the data is stored in a single file; attaching the single file to SQL Server automatically re-creates a transaction log so that the database can be used.

To attach a single-file database

Transact-SQL

SQL-DMO