locked
Cant create new database because SSMS says it already exists RRS feed

  • Question

  • User224181609 posted

    I had several databases up and running on my local SQLServer 2012 Management Studio.

    Today when I go to look, none of them show (see screen capture below).  So I try to add one back (in this case names MyNumbersTrackerDb) with the idea I will re-attach it to the aspnetdb.mdf file in the App_Data folder of my local website.  But I can't add the database because I get the error message that the database already exists.

    So the question: If it already exists, why can't I see it in the database list of SQL Server? How do I get out of this situation?

    Thanks

    Friday, July 13, 2018 7:56 PM

All replies

  • User224181609 posted

    Been playing around with this for quite a while. Not sure of the sequence of things but at some point I did a Save All and suddenly the databases appeared, although most of them indicated recovery pending (which was never going to finish).

    I deleted all those, and there was MyNumbersTrackerDb also showing but with no tables. So I decided to start from scratch and re-create that database. So I deleted it also, only to discover that the process deleted the aspnetdb.mdf database to which it was attached (located in my local websites App_Data folder). Maybe I should have known that would happen, but I know just barely enough about SQLServer to get what I need going :=(

    Lucky for me I kept a complete backup of the website while working on it (actually not luck, I did it just in case), so was able to replace the missing aspnetdb.mdf file in the website App_data folder.

    Finally, in SSMS, I created a new MyNumbersTrackerDB and successfully attached it to the aspndb.mdf file in the websites App_Data folder.  So for now, I am back in business and the database still shows up in SSMS when I close it and restart it.

    I am posting this in the possibility that some other user wandering through the haze of SQLServer Managment Studio may find it useful.

    Sunday, July 15, 2018 7:08 PM