Nevermore.us

SQL Administration

Quick and Easy way to mass detached all user databases in Microsoft SQL

by nevermore on Jun.23, 2009, under Networking, SQL Administration, work

So, i was cleaning up my “test server” and wanted to detach all the databases i had currently attached in MS SQL. Assuming you installed everything to their default locations this is all you should need to do in order to mass detach all the user db’s.

1. Install SSEUtil from here i recommend extracting it to c:\windows\system32 so you can run it from anywhere in the command line.
2. Run the following command:

sseutil -m -s localhost -user sa -pwd? -detach "C:\Program Files\Microsoft SQL Server\MSSQL\Data\*"

You should see output similar to the following:

Detached 'mydb1' successfully.
Detached 'mydb2' successfully.
Detached 'mydb3' successfully.

You can of course update localhost so that you can do this remotely and of course you can change the user.

SSEUtils has some other cool features as well for mass re-attaching.

anyway, more workieeeee for me before i head out to Matisyahu tonight.

laters
g-fiz

Leave a Comment :, more...

Looking for something?

Use the form below to search the site:

Loading

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!