Msg 5064, Level 16, State 1, Line 1
Changes to the state or options of database 'DbName' cannot be made at this time. The database is in single-user mode, and a user is currently connected to it.
Msg 5069, Level 16, State 1, Line 1
ALTER DATABASE statement failed.
the only thing will help you:
Get process id of active db connection using script:
select * from master.sys.sysprocesses
where spid>50 -- don't want system sessions
and dbid = DB_ID('DbName')
In my case I got 52.
And then execute:
use master
kill 52-- the connection to the database in single user mode
use [DbName]
alter database [DbName] set multi_user with rollback immediate
Or:
use master
kill 52-- the connection to the database in single user mode
alter database [DbName] set offline with rollback immediate
alter database [DbName] set online, multi_user with rollback immediate
Hope this will help you.
1 comment:
Thanks, it helps :P
Post a Comment