Friday, March 23, 2012

Lock database to update

Hi,

I need to lock a database (prevent users from connecting) in order to
update it. I already know how to kick everyone out with their spid but
i can't figure how to prevent them from reconnecting.

Thanks !Set the datbase in single user mode, so no one can reconnect.

ALTER DATABASE myDB SET SINGLE_USER WITH ROLLBACK Immediate
Markus|||It works, thanks a lot !|||It works, thanks a lot !|||Kittikun (kittikun@.gmail.com) writes:
> It works, thanks a lot !

And when you are done

ALTER DATABASE db SET MULTI_USER

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Thats good point Erland

Madhivanansql

No comments:

Post a Comment