database called “Active” into a database called “Training” once a we
ek. If
there are still students logged into the Training database the job fails and
I have to go and kill all the processes related to the Training databases so
that I can restart the job that copies that Active database to the training
database. Is there a t-sql script that I can use to kill all (1 – 500) the
users logged into Training database as a first step in a job before the copy
process?
Thanks
JosephSur you can do that by looping through the process and kill them by a cursor
basis, but the best thing would be to use ALTER DATABASE statement to set
the database to a "restricted" mode where you can do your maintainance. More
information in BOL under ALTER DATABASE e.g.
ALTER DATABASE <Nameofthedb> SET
SINGLE_USER with rollback immediate
Setting back after the maintainance:
ALTER DATABASE <Nameofthedb> SET
READWRITE with rollback immediate
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"Joseph" <Joseph@.discussions.microsoft.com> schrieb im Newsbeitrag
news:C44DC59D-FD66-4491-9620-84DB1A59CC0E@.microsoft.com...
> How do kill all the processes in a database? Here is my situation; I copy
> a
> database called "Active" into a database called "Training" once a w

> If
> there are still students logged into the Training database the job fails
> and
> I have to go and kill all the processes related to the Training databases
> so
> that I can restart the job that copies that Active database to the
> training
> database. Is there a t-sql script that I can use to kill all (1 - 500) the
> users logged into Training database as a first step in a job before the
> copy
> process?
> Thanks
> Joseph
>sql
No comments:
Post a Comment