I have a SQL Server deployment script running from visual studio that gives me the error:
Error SQL01268: .Net SqlClient Data Provider: Msg 1828, Level 16, State 5, Line 1 The logical file name “myDB” is already in use. Choose a different name.
However, when I go into SSMS and try and drop this database, I get the error:
Cannot drop the database ‘myDB’, because it does not exist or you do not have permission.
Can anyone help me understand where this phantom filename is already stored so that I can delete it?
Thanks.
The second error message states that the database cannot be dropped because other sessions are currently connected to it. In order to kick all the users out, you can add this to your deployment script or run it manually before deploying. The
USEcommand is to make sure there isn’t a race condition when you are the one who’s connected.