28.1 C
Cuttack
Thursday, March 14, 2024
HomeSQL ServerAn error occurred when attaching the database(s). Click the hyperlink in the...

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

To START and STOP SQL Server Service

Go to run type services.msc once that page opens search for SQL Server Service 
and STOP it from the left panel. Same process to START the SQL Server Service

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 Ojhahttps://lifeonnetwork.com/
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.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular