Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DROP DATABASE

Status
Not open for further replies.

VBXL

Programmer
Joined
Jul 10, 2001
Messages
198
Location
GB
I cannot access the database and when I try and drop it is says I cannot because it is in currenlty in use. How do i drop a database in T-SQL when it is in use.


Cheers
 
First, make sure you are logged in with Administer rights. Second, I suggest opening up Enterprise Manager, expanding your server, expand Management, expand Current Activity, and click on Process Info. This will show you what users are logged on and to what database they are using. You need to log any users off the database (KILL command). You might also have to set the database to SINGLE_USER (see BOL). Lastly, make sure your TSQL script is correct.

USE MASTER
DROP DATABASE <databasename>

You must USE MASTER when dropping any user database and you cannot drop the system databases (master, msdb, tempdb, model).

-Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top