Wednesday, March 21, 2012

getting rid of sql express databases

This issue is just irritating: hope someone can help...

I recently deleted a whole lot of test websites on my laptop by physically deleting the folders. Each had their own SQL Express database. The database instances still show up in SQL Server Management Studio, although the databases have been removed. I can't drop the datababases with the GUI as it says they're not accessible (that would be right), and manually using the DROP DATABASE command tells me that the physical file can't be found (also correct).

Is there a "proper" way to get rid of them without directly manipulating the system tables?

This is a tricky situation.

One way to get the instances name not to show up in the GUI is to remove entries from the system tables.

Or, you could goto the Recycle Bin and restore the database files and try to delete the database from GUI again. Hope you did not use "Shift + Delete"

|||

I think that could be accomplished with the tool called sseutil, found here:http://www.microsoft.com/downloads/details.aspx?familyid=fa87e828-173f-472e-a85c-27ed01cf6b02&displaylang=en

Specifically look at the -d option

hope it helps,

/Klaus

|||

Klaus Byskov Pedersen:

I think that could be accomplished with the tool called sseutil, found here:http://www.microsoft.com/downloads/details.aspx?familyid=fa87e828-173f-472e-a85c-27ed01cf6b02&displaylang=en

Specifically look at the -d option

hope it helps,

/Klaus

Klaus,

That is a great tool. Hope the poster will be able to resolve the issue using this tool.

|||

Klaus, that worked - thanks! I'd forgotten sseutil, I rarely use it. For anyone else who need to do this, the tool has minimal documentation so here's the quick steps:

1. download and install sseutil using Klaus' link

2. list the databases on your local server (from the command-line prompt)

sseutil -l

3. Use the -d parameter to "detach" the database, this tool doesn't complain that the files aren't in place. Here's my example:

sseutil -d "C:\WEBSITE1\APP_DATA\ASPNETDB.MDF"

Unfortunately, I also have several ASPNETDB databases that get listed without a path but with a suffix e.g.ASPNETDB_82786741c8bb45919d200a59f159d29c. The sseutil utility can't deal with these, so I think I'll need to tinker with the system tables here. But the other ones have "disappeared" nicely.

sql

No comments:

Post a Comment