Operating system error 5 (Access is denied), or What to do when you can’t attach a SQL Server database?

It’s really simple. I went through a lot of pages that mostly advised changing the account the SQL Server service runs under to your own account, but I didn’t want to do that. After all, if it were meant to be that way, MS would have set it up like that, and it wouldn’t run under the special account NT Service{nazev_vasi_sql_instance}. After a while, though, I came across the page http://web.archive.org/web/20140620004908/https://connect.microsoft.com/SQLServer/feedback/details/539703/access-denied-attaching-a-database-when-permissions-are-inherited , which has helped me with this problem many times before; I just never remember how I solved it the previous times. The solution is that you have to run the program you want to use to attach the DB (most likely MS SQL Server Management Studio) as administrator. Then it will attach the DBs and you can work with them. There’s no need to set any permissions for any accounts on the database folder – just run it as administrator and you’re done. I’ve finally written it down here, because whenever I have a problem, I search my own blog first, and only when I don’t find it here do I google everywhere else.



Newly attached DB TypeScriptCompiler.mdf

Categories

Leave a Reply