Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Permissions error when attaching a database: "Cannot access the specified path"

I am running SQL Server 2012 Enterprise Edition. I have downloaded the AdventureWorks 2012 OLTP data files (both .mdf and .ldf). I saved them to the AW folder that I created in My Documents where I unzipped the file. I go to SQL Server Management Studio (SSMS) right-click on database, and click attach in the context menu. In the dialog I click find.

The UI does not allow me to navigate to folder. I try typing the full path to the file, and then I get the following error:

Cannot access the specified path or file on the server. Verify that you have the necessary security privileges and that the path or file exists.

I closed SSMS and restarted it, this time running as the administrator. Same bad result.

This should not be this hard. What are the exact steps to successfully attach the AdventureWorks2012 database to SSMS?

Thanks!

like image 877
user2151027 Avatar asked Mar 09 '13 08:03

user2151027


People also ask

How to fix when Windows cannot access the specified path?

Disable antivirus software temporarily. Check permission of the file or folder. Unblock the file. Check the location of the file. Recover the removed file or deleted file. In this section, we will list 5 solutions to solve the problem when Windows cannot access the specified path.

Why can't I attach a database to a file?

This behavior is not a bug, but rather by design to make sure the login attaching the database has sufficient permissions on the files and not leveraging the SQL Server service account to attach files they do not own.

Why can't I access the specified device or file?

You are seeing the message "Windows cannot access the specified device, path, or file. You may not have the appropriate permissions to access the item" because of one of the following reasons. You don't have permissions to the file, the folder or the drive.

How to fix “Windows cannot access a file” error?

Step 1: Right-click the file which has the problem Windows cannot access the specified path and choose Properties to continue. Step 2: In the popup window, go to the General tab. Then you will see a message The file came from another computer and might be blocked to help to protect the computer if the file is blocked by Windows.


2 Answers

Connecting to the server by Windows Authentication worked for me. I don't know if that is possible in your case.

like image 79
Rogitel Avatar answered Sep 21 '22 06:09

Rogitel


As Rogitel says about, this could be related to how you have logged in to SSMS itself, rather than the privilege level of the application.

It seems as though, if your user does not have the "sysadmin" role, then they will not have sufficient access to the filesystem on the machine in order to open the file browser.

Setting aside the security concerns for one moment....

In order to grant this role;

  1. Log in to SSMS using Windows Authentication
  2. Navigate to Security->Logins
  3. Either double Click, or Right Click and select Properties on the user you're interested in .
  4. In the "Select a page" box, select "Server Roles"
  5. Make sure that the "sysadmin" role is selected
  6. Press Ok to save the change and close the dialog
  7. Exit SSMS
  8. Reopen SSMS and login as the User you wanted, and you should now have sufficient Privileges to browse.
like image 39
PGallagher Avatar answered Sep 19 '22 06:09

PGallagher