IdleTymes Blog

Personal Diary, Musing and rubish of a F*!^%#g bored programmer.

scene one: Using TSQL to Detach a database

05 23rd, 2005 Author: Administrator

Detaching a database is always been a sour spot every company since the beginning of time, when whole tribes of cavemen would fight bloody wars over wether to use Enterprise Manager or Type it into Query Analyzer. Well, ever since the invention of the spear, the Enterprise Manager side have been dominating the argument so I just like too insert my Pro Query Analyzer Propergander:

Query Analyzer allows you to write scripts , so you don`t thave to do all that slow click, wait, click wait, rubbish. Yes admittable it requires you to perpare a script, but hay I`m here to make it simple for you.

This is all you need to type:

USE master

Execute sp_detach_db @dbname = [dbname]

Then just repeat the last line for each database you want to detach. It that simple*

*unless anyone is logged in then it becomes vastly more complicated, but don`t mention that to anyone with a pointed stick. See Killing process off in TSQL, Query Analyzer incredible over complicated answer to it.


Comments are closed.