There is another variation of the Access Denied message that has a simple solution:įailed to retrieve data for this request. By copying the files to this directory, they automatically get permissions applied that will allow the attach to succeed. On my machine it is: C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA. To find out what that is, you can use the sp_helpfile procedure in SSMS. A final solution is to copy the files to the default directory for your other database files.This can be done by right-clicking the files, selecting Properties, and modifying the Security tab.
#VISUAL STUDIO 2017 SQL SERVER LOCAL FULL#
#VISUAL STUDIO 2017 SQL SERVER LOCAL WINDOWS#
Remember in Windows 7/Vista, those permissions are often only realized when you’re running an application as an Administrator. Also, even if you see that the file has full control for the Administrators group, it may not be enough. When they detach the database file, the file permissions are changed to give only that user full control. This can happen if you get the file from someone else. Basically, you don’t have the required access to the. This access denied error could have a few different causes. Operating system error 5: “5(Access is denied.)”. But if you see any errors or unexpected behaviors, I’ll try to share some troubleshooting suggestions.įirst, you may get a generic error like the following.Īttach database failed for Server #. If your database is successfully attached, then stop reading and go use it. Or you can use the CREATE DATABASE command with the FOR ATTACH argument. First, you can use the sp_attach_db stored procedure. There are two ways to accomplish the same thing in a T-SQL script. I’m just summarizing to make it easier for you. These same steps are documented in the MSDN here. You should see the database appear in the Databases node (press F5 if you don’t). Navigate to the directory containing the.In the Attach Databases window, click the Add button.Right-click on Databases in the Object Explorer.I’ll give you the “easy” way through SQL Server Management Studio (SSMS) and then point you to other methods using T-SQL queries.