Restore to diff server

  • 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

  • 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.

  • 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.

  • I bow to the master guru for a much simpler and more elegant solution.

  • 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.

  • 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?

  • 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