Attaches a database having only one data file to the current server.
sp_attach_single_file_db [@dbname =] 'dbname',
[@physname =] 'physical_name'
0 (success) or 1 (failure)
None
When sp_attach_single_file_db attaches the database to the server, it builds a new log file and performs additional cleanup work to remove replication from the newly-attached database.
Used sp_attach_single_file_db only on databases that were previously detached from the server using an explicit sp_detach_db operation.
Only members of the sysadmin fixed server role can execute sp_attach_single_file_db.
This example detaches pubs and then attaches one file from pubs to the current server.
EXEC sp_detach_db @dbname = 'pubs'
EXEC sp_attach_single_file_db @dbname = 'pubs',
@physname = 'c:\mssql7\data\pubs.mdf'
sp_attach_db | sp_helpfile |
sp_detach_db | System Stored Procedures |