Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Terminating Users

Author  Topic 

catparks
Starting Member

18 Posts

Posted - 2005-07-13 : 11:25:54
I have a DTS job that drops a database and restores it as read-only everyday. The job fails when a user is using the database at the time the job attempts to drop the database. Does anyone know how I can terminate all users before the job begins?

Thanks!

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-07-13 : 12:50:10
ALTER DATABASE DBNameGoesHere SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO

Tara
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-07-13 : 12:51:42
I think this will work:

alter database <Database_name> set single_user with rollback immediate

Be One with the Optimizer
TG
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-07-13 : 12:52:59
ah, some things never change... by Tara

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -