What do you mean I can’t access my own database when trying to attach it?

Published On: 2009-08-06By:

When you detach a database from Microsoft SQL (I’m talking SQL Server 2005 and up here) the SQL Server automatically changes the NTFS permissions on the file so that only the user who told the SQL Server to detach the file has access to them.  SQL Server does this to ensure that an unauthorized person isn’t able to access the data files.

However the downside to this security measure is that the SQL Server also doesn’t have access to the files when you try to attach the files back to the server, which will cause SQL Server to throw a permissions error when attaching the database weather using SQL Server Management Studio or T/SQL.  Because of this you’ll need to edit the NTFS permissions for all the files on the SQL Server and give the SQL Server service full control rights to the database files.


Contact the Author | Contact DCAC

One response to “What do you mean I can’t access my own database when trying to attach it?”

  1. BrentOzar says:

    This one caught me by surprise just a couple of weeks ago. Took me damn near an hour to figure it out.


Globally Recognized Expertise

As Microsoft MVP’s and Partners as well as VMware experts, we are summoned by companies all over the world to fine-tune and problem-solve the most difficult architecture, infrastructure and network challenges.

And sometimes we’re asked to share what we did, at events like Microsoft’s PASS Summit 2015.

Awards & Certifications

Microsoft Partner   Denny Cherry & Associates Consulting LLC BBB Business Review    Microsoft MVP    Microsoft Certified Master VMWare vExpert
INC 5000 Award for 2020    American Business Awards People's Choice    American Business Awards Gold Award    American Business Awards Silver Award    FT Americas’ Fastest Growing Companies 2020   
Best Full-Service Cloud Technology Consulting Company       Insights Sccess Award    Technology Headlines Award    Golden Bridge Gold Award    CIO Review Top 20 Azure Solutions Providers
Share via
Copy link