Hi, I'm trying to drop the connections of a database using this command :
"alter database dbName set single_user with rollback immediate "
But u got this error "ALTER DATABASE failed because a lock could not be placed on database 'dbName'. Try again later."
Please I need help as soon as possible.
Regards
Tamer Khalil
How to drop all database connections?
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.


naura paxRank #2,843 · 502 reputationPosted Oct 23, 2009, 6:16 AM EDT
ALTER
DATABASE mydb SET OFFLINE WITH ROLLBACK IMMEDIATE
and then run this to run database again.
ALTER DATABASE mydb SET ONLINE WITH ROLLBACK IMMEDIATE
naura paxRank #2,843 · 502 reputationPosted Oct 23, 2009, 5:38 AM EDT
is AUTO_UPDATE_STATISTICS_ASYNC option set to on then set it to off and also check if their are any active jobs in the server from
select * from sys.dm_exec_background_job_queue
if there are any jobs then kill them using KILL STATS JOB
Tamer KhalilRank #2,182 · 647 reputationPosted Oct 23, 2009, 5:51 AM EDT