I was trying to attach a SQL Database into local SQL Express and got an error “Unable to open the physical file. Operating system error 5. 5(Access is denied)”. The reason is for the lack of permissions. The default data directory has Full control permission to MSSQL$SQLEXPRESS. If you want to attach a database in a different location then you should add the permission to that directory.
Error
-
Error occurred when attaching a database
Unable to open physical file - Operating system error 5: 5(error not found) Microsoft SQL Server: Error 5120
Test environment
Solution
-
Add Full control to MSSQL$SQLEXPRESS to the specific directory