I have over 1,000 databases to detach from a list of 5,000.. I have been doing it through the GUI..
Right Click Tasks Detach Drop Connections & Update Statistics..
This got boring real fast....
Anyhow.... is there a command I could type in a New Query or something to automate this process?
Would either of the commands below work and also Drop Connections & Update Statistics?
Where would I even type the command?
Could I just keep adding lines to detach a bunch of DB's in one script?
Is there anything I should be concerned about?
What if the DBdoesn'texist or has already been detached.. will it just skip to the next line with maybe an onscreen error?
- Windows Server 2008 R2 64-Bit
- MS SQL Server 2008 R2
SQL
EXECsp_detach_db'DATABASEname001','true';<-MaybeFalse
SQL
EXECsp_detach_db'DATABASEname002','true';<-MaybeFalse
or
SQL
USEmaster;GO...