Home > Archive > Microsoft SQL Server forum > February 2006 > Lock database to update









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Lock database to update
Kittikun

2006-02-21, 9:23 am

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 !

m.bohse@quest-consultants.com

2006-02-21, 9:23 am

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

ALTER DATABASE myDB SET SINGLE_USER WITH ROLLBACK Immediate
Markus

Kittikun

2006-02-21, 11:23 am

It works, thanks a lot !

Kittikun

2006-02-21, 11:23 am

It works, thanks a lot !

Erland Sommarskog

2006-02-25, 9:44 am

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
Madhivanan

2006-02-25, 9:44 am

Thats good point Erland

Madhivanan

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com