title: SQL Server Operating system error 5: "5(Access is denied.)"
body: <p>I am starting to learn SQL and I have a book that provides a database to work on. These files below are in the directory but the problem is that when I run the query, it gives me this error:</p>
  
  <blockquote>
    <p>Msg 5120, Level 16, State 101, Line 1 Unable to open the physical file
    "C:\Murach\SQL Server 2008\Databases\AP.mdf". Operating system error
    5: "5(Access is denied.)".</p>
  </blockquote>
  
  <pre><code>   CREATE DATABASE AP
        ON PRIMARY (FILENAME = 'C:\Murach\SQL Server 2008\Databases\AP.mdf')
        LOG ON (FILENAME =     'C:\Murach\SQL Server 2008\Databases\AP_log.ldf')
        FOR ATTACH
      GO
  </code></pre>
  
  <p>In the book the author says it should work, but it is not working in my case. I searched but I do not know exactly what the problem is, so I posted this question.</p>