Home > SQL Server > An error occurred when attaching the database(s). Click the hyperlink in the Message column for details

An error occurred when attaching the database(s). Click the hyperlink in the Message column for details

An error occurred when attaching the database(s). Click the hyperlink in the Message column for details

An error occurred when attaching the database(s). Click the hyperlink in the Message column for details.

While attaching .mdf and .ldf database files in SQL server management studio, it throws error attached image – 1

An error occurred when attaching the database(s). Click the hyperlink in the Message column for details

Image – 1

It seems permission issue for which it gives this error while attaching the .mdf and .ldf file. so to make it work, we need to give permission to the folder containing the database (.mdf, .ldf). else directly to the database files.

As shown in Image – 2. it does not have full control for which it throws error while attaching database.

An error occurred when attaching the database(s). Click the hyperlink in the Message column for details

Image – 2

Now I have given Full Control access to the Users for those .mdf and .ldf file as shown in Image – 3

An error occurred when attaching the database(s). Click the hyperlink in the Message column for details

Image – 3

Now do the same process to attach the .mdf file by right clicking on database and locate the .mdf file to restore.

This time database will get attached successfully without giving any error.

Another way you to overcome this error

while attaching the .mdf file is to stop the SQL Server service first

and then put the .mdf and .ldf inside Data folder where SQL Server was installed and then restart the SQL Server service, then attach the .mdf file. it wont give permission error.

You might also like:

How to truncate a SQL Server Data file

How to Backup a Database using SQL Management Studio

How to Restore Database using SQL Management Studio

Failed to connect to MySQL at with user root cannot connect to MySQL server on (10060)

Durga Charan Ojha
I am a proud Indian, proud father, a blogger, Being in a profession as System administrator, my passion is troubleshooting computer issues, I do like sharing solutions through blogging making videos of solving issues.
https://lifeonnetwork.com/

Leave a Reply

Your email address will not be published. Required fields are marked *