Re: How to close all connections to do backup programmatically?

From: Dan Guzman (guzmanda_at_nospam-online.sbcglobal.net)
Date: 11/11/04


Date: Wed, 10 Nov 2004 21:43:51 -0600

You can execute:

ALTER DATABASE MyDatabase
SET RESTRICTED_USER
WITH ROLLBACK IMMEDIATE

and

ALTER DATABASE MyDatabase
SET MULTI_USER

afterward.

However, one does not normally quiesce the database to perform backups. A
Transact-SQL BACKUP DATABASE command will guarantee transactional integrity,
even if you have active users.

-- 
Hope this helps.
Dan Guzman
SQL Server MVP
"Trieu Anh Dung" <dungniit@yahoo.com> wrote in message 
news:Ol1xH75xEHA.4044@tk2msftngp13.phx.gbl...
> Hi all,
> I'm using SQL Server 2K on Win2K to develop a window-based application 
> using
> .NET framework. Now I have to implement a function that query database and
> make backups, I want to close all concurrent connection on SQL Server 
> before
> running the backup process. Please help me!
> Thanks for reading!
>
> TrieuAnhDung
>
> 


Relevant Pages

  • Re: Setting Database Access
    ... ALTER DATABASE MyDatabase ... Most good judgment comes from experience. ... instances of SQL Server 2000 on the same server. ... set the database access on the other instance to Read only, ...
    (microsoft.public.sqlserver.security)
  • Re: How to close all concurrent connections to a database?
    ... ALTER DATABASE MyDatabase SET SINGLE_USER WITH ROLLBACK IMMEDIATE ... and after the task u can set the database to multi user ... > I'm wondering how to detect and close all concurent connection to a> database in SQL Server 2000. ...
    (microsoft.public.sqlserver.connect)