Prettylib-tuoteratkaisut - Wiki

sp_attach_single_file_db

Tietokantatiedoston liittäminen (ei varmuuskopiota saatavilla) SQL Serveriin.

Micrsoftin tukiartikkkelista:

sp_attach_single_file_db (T-SQL) 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)

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.

Use 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 fixed server role can execute sp_attach_single_file_db.

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'