Transact-SQL Reference

sp_attach_single_file_db

Attaches a database having only one data file to the current server.

Syntax

sp_attach_single_file_db [ @dbname = ] 'dbname'
    ,
[ @physname = ] 'physical_name'

Arguments

[@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.

Return Code Values

0 (success) or 1 (failure)

Result Sets

None

Remarks

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.

Permissions

Only members of the sysadmin and dbcreator fixed server roles can execute this procedure.

Examples

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'

See Also

sp_attach_db

sp_detach_db

sp_helpfile

System Stored Procedures

'

Comments ( )
Link to this page: //www.vb-net.com/Sql/Sql/Ts_sp_ae-az_4wrm.htm
< THANKS ME>