MS SQL Server Concepts and Programming Question:
Download Questions PDF

Why I am getting this error when dropping a database in MS SQL Server?

Answer:

If you are trying to drop a database that is in use, you will get an error message like this: 'Cannot drop database "GlobalGuidelineData" because it is currently in use.'

Before dropping a database, you must stop all client sessions using this database. If your own client session is using this database, you should set a different database as the current database as shown in this tutorial example:

CREATE DATABASE GlobalGuidelineData
GO

USE GlobalGuidelineData
GO

DROP DATABASE GlobalGuideLineDatabase
GO
Msg 3702, Level 16, State 4, Server LOCALHOSTSQLEXPRESS
Cannot drop database "GlobalGuideLineDatabase" because it is
currently in use.

USE master
GO

DROP DATABASE GlobalGuideLineDatabase
GO


Download MS SQL Server Interview Questions And Answers PDF

Previous QuestionNext Question
How to delete a database in MS SQL Server?How to get a list all databases on the SQL server?