Ads Top

Fix: Cannot detach the database ‘DBName’ because it is currently in use. (Microsoft SQL Server, Error: 3703)

Many times SQL developers faces this problem, and you cannot find with instance is using database... there is the simple solution.
First: Run This query.....

---------------------------------------------------------------------------------------------------------------
select d.name, d.dbid, spid, login_time, nt_domain, nt_username, loginame
from sysprocesses p inner join sysdatabases d on p.dbid = d.dbid
where d.name like '%YOUR DB NAME%'

---------------------------------------------------------------------------------------------------------------

Second: Then Run the following query

---------------------------------------------------------------------------------------------------------------
go
kill 53
go 
---------------------------------------------------------------------------------------------------------------

try to delete database.... Or
You may also need to Run this query

---------------------------------------------------------------------------------------------------------------

ALTER DATABASE [YOUR DB NAME] SET OFFLINE WITH ROLLBACK IMMEDIATE

---------------------------------------------------------------------------------------------------------------

No comments:

Powered by Blogger.