none
SQL Server: adding a database: access denied

    Question

  • Hi I am in an SQL Database online class and I need to have the database attached to the sql server, but when I try this by dragging and dropping it into the managment studio is says there is no editor available for (gives the pass of file) make sure the application for the file type (.mdf) is installed. When I try and attach it like the book says it says access denied. please not I am running Windows 7. I've looked on the web for a solution, but it seams like alot of people are having this problem and i've seen some people saying you need to give the SQL server more right, but I have no clue how to do this, can anyone help me with this problem?

    Thanks

    Tuesday, February 08, 2011 2:25 PM

Answers

  • Thank you for your help, but I figured it out. I had to right click on it and run the studio as administrator. Gotta love Windows 7, you can be an administrator and not be one at the same time.

    Thanks again

    Wednesday, February 09, 2011 8:54 PM

All replies

  • Hello,

    You can't add a database by Drag & Drop.

    Please open the Management Studio (SSMS), connect to the SQL Server. In SSMS right mouse click on node "Databases" => "Attach ..." and select there the .MDF and .LDF file of the database you want to attach.


    Olaf Helper ----------- * cogito ergo sum * errare humanum est * quote erat demonstrandum * Wenn ich denke, ist das ein Fehler und das beweise ich täglich http://olafhelper.over-blog.de
    Tuesday, February 08, 2011 2:38 PM
  • Thank you for getting back to me.

    I've tried that, but it says an error occurred when attaching the database. click the hyperlink in the message column for details, but there is no hyperlink to click on. Then I click ok on the screen and in the database to attach section, under message I click on Attach and it says, Attach database failed for server 'locolhost\SQLEXPRESS'. (Microsoft.SqlServer.Smo)

    Additional Information

    An exception occurred while executing a Transact-SQL statment or batch. (Microsoft.SqlServer.ConnectionInfo)

    Unable to open the physical file (gives link to file). Operating system error 5: "5(Access is denied.)". (Microsoft SQL Server, Error 5120)

     

    Any ideas on what that all means?

    Thanks

    Mike

    Tuesday, February 08, 2011 2:57 PM
  • Hello Mike,

    Have you downloaded the .MDF file from internet? Then you have to "unblock" the file to get access. Or have you copied the .MDF for CD/DVD? Then it's readonly, you have to remove the readonly flag on file system level.


    Olaf Helper ----------- * cogito ergo sum * errare humanum est * quote erat demonstrandum * Wenn ich denke, ist das ein Fehler und das beweise ich täglich http://olafhelper.over-blog.de
    Tuesday, February 08, 2011 3:13 PM
  • Thank you for your help, but I figured it out. I had to right click on it and run the studio as administrator. Gotta love Windows 7, you can be an administrator and not be one at the same time.

    Thanks again

    Wednesday, February 09, 2011 8:54 PM
  • Gotta love Windows 7, you can be an administrator and not be one at the same time.

    You have to differentiate between Windows administrator and SQL Server administrator (= SysAdmin); that's not the same.
    Olaf Helper ----------- * cogito ergo sum * errare humanum est * quote erat demonstrandum * Wenn ich denke, ist das ein Fehler und das beweise ich täglich http://olafhelper.over-blog.de
    Thursday, February 10, 2011 7:34 AM