Home > SQL > cannot drop database because it is currently in use

cannot drop database because it is currently in use

1) While trying to drop the database dont use the same database name.

USE Master;
GO


DROP DATABASE TestDB;
GO

2) But again you are getting the same error, then completly close SQL Server Management Studio . Open it again and connect. Now try to run the below script

USE Master;
GO


DROP DATABASE TestDB;
GO

3) Still if u get the error, then find sessions of the database that you are trying to drop

EXEC sp_who2
--Run kill SPID for each process that is using the database to be dropped.
kill <SPID> -- Kill 57
Advertisements
Categories: SQL
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: