Attach/Detach sql server database

Copper Contributor

I had sql server 2014 installed in my pc on hard drive c:. But then I wanted to improve the pc performance by installing an ssd drive instead of the physical hard drive without taking the precaution to detach or backup my sql server database. I am now using the original hard drive as an external one.

After reinstalling sql server and sql server management studio I can't attach the sql server database from the hard drive to the (new) sql server instance in my pc. 

Is there a way to proceed in order  to attach the  database  from the external hard disk to the sql server? 

6 Replies

After reinstalling sql server and sql server management studio I can't attach the sql server database from the hard drive to the (new) sql server instance in my pc. 

 


@bboudj , what in detail means "you can't"? Do you get an error message and if, which one?

@olafhelper 

Hi; Using ssms and right clicking on database tab on the left panel, opens a contextual windows with the option of attaching a database. Trying to do just this I get error 5123.


Trying to do just this I get error 5123.

@bboudj , please post the complete error message, not only the number.

@olafhelper 

Thanks for your support. I got tired of trying to attach the database to  the new instance of sql on the ssd drive. But each attempt failed. So I reinstalled my old system hard disk on my pc and had sql server detach  the database after which I removed the hard disk and reinstalled the ssd drive. I still have to attach the database to sql server. I will try this later. Again thank you for enquiring.

You still didn't provide any usefull information and also not the error message; it's impossible to assist you.
As you have mentioned you are facing an error 5123, There are 2 steps to attach your database if you are not able to do that.
Granting permissions: You need to right-click on properties and then under properties select security and edit on permissions and provide the full control access by selecting allow in full control.
Try attaching the database in SQL Server using any of the following methods:
1) BY SSMS: By adding in SSMS
2) By T SQL