An error occurred when attaching the database(s). Click the hyperlink in the Message column for details
Try running SQL Server Management Studio as administrator
I had this problem as well, I did right click on (.mdf
and .ldf
) the file then on the security tab, click on Edit.
In a new window find the users and set permission to full control. If you can't find users click on:
add button-->advanced-->Find now-->find users
and then click on Ok. if it doesn't work you can backup from your database and restore it instead of attaching. I have done it and it works.But before restoring make sure that your DB (.mdf and .ldf) shouldn't exist in SQL server database directory before restoring (it's up to your SQL server installation path in my case -->C:\Program Files\Microsoft SQL Server\MSSQL12.SQL2014\MSSQL\DATA) otherwise you will face to an error
All of the answers I've seen so far are possible suggestions of what could be the issue, but it doesn't necessarily help you identify the issue that's preventing you from attaching this database.
The error message you are referring to is actually pointing you to a more specific error message for your case. This more specific error message is located in the Message column of the "Attach Database" window that you've already opened (you may just need to scroll to the right of the "Databases to attach" section and click on the message to see it in its entirety.