Attaches a database having only one data file to the current server.
sp_attach_single_file_db [ @dbname = ] 'dbname'
, [ @physname = ] 'physical_name'
[@dbname =] 'dbname'
Is the name of the database to be attached to the server. dbname is sysname, with a default of NULL.
[@physname =] 'phsyical_name'
Is the physical name, including path, of the database file. physical_name is nvarchar(260), with a default of NULL.
0 (success) or 1 (failure)
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 and dbcreator fixed server roles can execute this procedure.
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:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs.mdf'
|This HTML Help has been published using the chm2web software.|