Re: force process termination on restore
From: Hari Prasad (hari_prasad_k_at_hotmail.com)
Date: 08/16/04
- Next message: Hari Prasad: "Re: Please Help : SQLServerAgent cannot start"
- Previous message: anonymous_at_discussions.microsoft.com: "Re: sysprocesses - sp_who"
- In reply to: Jason: "force process termination on restore"
- Next in thread: slamm: "Re: force process termination on restore"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 16 Aug 2004 20:09:02 +0530
Hi,
There are 2 approaches...
1. If you are restoring in non production then you could disconnect all the
users using below command
ALTER database <dbname> set single_user with rollback immediate
go
Restore database
go
ALTER database <dbname> set multi_user
2. Write a loop sort to check the sysprocesses table for this particular
database for any running process . If there
is any running processes
start1:
if (select status from master..sysprocesses where status='runnable' and
db_name(dbid)='pubs')>1
waitfor delay(........) -- set 1 minutedelay
goto start1
else
kill all the users connected
restore the database
I recommend the first method for development and test server databases.
Thanks
Hari
MCDBA
"Jason" <Jason@discussions.microsoft.com> wrote in message
news:03CD2B22-81B6-4EB1-B782-A86E2C6EF9A1@microsoft.com...
> Sorry if this is a dumb question, but we have several production databases
> that get automatically backed up, Rar'd, FTP'd internally and then
restored.
> Problem is, if someone has a process open against the restored database
(IE:
> a report is being run or something) the restore fails.
> There must be a way of making the restore wait until a process is finsihed
> or to force a termination of any process (altho probably not a good
practice)
> that is running.
> Basically, I'm just looking for a better backup/restore process. Any
ideas?
- Next message: Hari Prasad: "Re: Please Help : SQLServerAgent cannot start"
- Previous message: anonymous_at_discussions.microsoft.com: "Re: sysprocesses - sp_who"
- In reply to: Jason: "force process termination on restore"
- Next in thread: slamm: "Re: force process termination on restore"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|