Step5: On Selecting MDF File just go to Ok to complete the job
Step6: You can also attach SQL MDF file without LDF File by removing it after
selecting MDF file also.
Step7: Check your attached database in a list of Database
Another Approach to attach a database by using T-SQLQuery
- Establish a connection with Database Engine.
- Just click on New Query.
- Type in New Query Window the below statement with For Attach close i.e
- CREATE DATABASE statement with the FOR ATTACH close. For example
CREATE DATABASE Mypersonalwork
ON (FILENAME = 'C:\MSSQLServer\Mypersonalwork.mdf'),
(FILENAME = 'C:\MSSQLServer\Mypersonalwork_Log.ldf')
FOR ATTACH;
Note:
|
You may also go with sp_attach_db or sp_attach_single_file_db stored procedure. But in future version of Microsoft SQL Server these procedures will be removed. So you must apply this approach which serves a better way to attach SQL MDF Files quickly. |
No comments:
Post a Comment