Why would you need to attach a database to MSSQL Server? Sometime when your system fails and you only manage to backup a your .MDF file(s) and no backup is available.
Step 1
Then in order to activate your database again, or attach it to a healthy running system, use to following command :-
exec sp_attach_db @dbname='Demo',
@filename1='D:\Demo\Demo_data.mdf',
@filename2='D:\Demo\Demo2.mdf',
@filename3='D:\Demo\demo_log.ldf'
Step 2
Detaching a database can be accomplish by executing the following command
EXEC SP_DETACH_DB Demo
Whereby Demo is our database name.
No comments:
Post a Comment