December 4, 2002 at 10:30 am
What I want to do is have a scheduled job to restore production DB to test server. Unfortunately, developers often leave SQL EM or QA windows open overnight, which will cause the restore to abort. I want to kill processes using the DB on the test server prior to executing the restore command. Can I run a query to a cursor that will identify PIDs using the DB and then execute KILL 'variable' in the cursor? If so, what table in what DB would I query on? TIA - Al
December 4, 2002 at 11:05 am
In a simple answer: yes!
For details, I would look at the (undocumented) sp_who2 stored proc to see where it retrieves its info from. You can use the same logic to issue nice, friendly "you're toast" messages to your programmers.
December 4, 2002 at 1:00 pm
Another possible way is like so.
ALTER DATABASE dbname
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE
then run your restore and take out of single user mode.
December 4, 2002 at 1:08 pm
I bow to the master guru for a much simpler and more elegant solution.
December 4, 2002 at 2:52 pm
Don't bow to me, I stole it from someone else a week or so ago and thought was cool option. I like to find new ways to do things and pretty much remember all the conversations I have had here.
December 4, 2002 at 3:08 pm
Then I salute you as a fellow thief and master plagiarizer. I'm still modifying code I stole years ago. I don't think any new code is being written anywhere.... just old code constantly being upgraded. Are there any new problems to solve in data processing?
December 5, 2002 at 3:40 pm
I am sure there are always new solutions to old problems and so on but most code and information is surely rehashed and updated.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply