Attach / Detach Database OSQL Example
This page has examples on how to attach and detach MS SQL Server databases with TSQL commands:
http://www.mssqlcity.com/Articles/Adm/attach_database.htm
To detach:
EXEC sp_detach_db 'pubs', 'false';
- switch the 'false' for 'true' if the database files do not exist.
- don't forget the semi colon.
To attach:
EXEC sp_attach_db @dbname = 'pubs',
@filename1 = 'C:\MSSQL\Datapubs.mdf',
@filename2 = 'C:\MSSQL\Datapubs_log.ldf'
-----------------
Tags: mount, unmount, osql, remove, offline
>>
Leonard Chan's Homepage
>>
Scribble Web
>> Attach / Detach Database OSQL Example