0
I'm working with a bunch of *.mdf files which I'm attaching on my local computer. After I accidentally deleted the a folder containing some of the *.mdf files, I'm unable to view the databases in SQL Management Studio, and therefore can't detach them.
When opening SQLMS I'm getting the error:
Unable to open the physical file "D:\Foo\bar.mdf".
Operating error 5: "5(Access is denied)". (Microsoft SQL Server, Error: 5120)
I have backups of the files, and even if I restore the files, I still get this error.
After restoring the file to the original path, I'm trying to re-attach the database from file, but get the error:
Cannot attach a database with the same name as an existing database.
But I can't see the previous database either, so I can't detach it.
How do I detach/remove/delete the old database so I can re-attach it from file?
Thanks! I tried stopping and starting the database earlier, but I might have forgotten to copy the files back or something then. That worked now, however, and I was able to delete and re-attach the databases. – steffen – 2014-04-04T11:11:37.567