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)
 Command Prompt file

Author  Topic 

vdavid70
Yak Posting Veteran

67 Posts

Posted - 2006-11-02 : 12:43:19
Hi All,
I am trying to create a job win sql server 2000. Which requires that the services running the application be stopped before i can run a restore database script.

I can stop the services manually by going to command prompt and changing directory to where the batch file to stop the services resides and type niku stop all.

But i want to be able to stop the services by creating a sql server job to do this, when that is done it should run the script that restores the database. Finally another script should restart the services.
Anyideas on how to do this.

nr
SQLTeam MVY

12543 Posts

Posted - 2006-11-02 : 12:49:08
Have a look at xp_cmdshell to stop the services.
The restore would be via t-sql.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-11-02 : 13:17:15
Are you wanting to stop the service to prevent people trying to access the database during the restore? Because if so you could just set the database to single user (which will disconnect everyone else) and then do the restore ...

Kristen
Go to Top of Page

vdavid70
Yak Posting Veteran

67 Posts

Posted - 2006-11-06 : 05:31:53
Hello,

I actually set the database to single user mode inorder to do the restore. But this doesnt work. Then i go into current activities to check for running processes. I use the kill command to kill these processes. But there are several processes that keep coming bac, thiese processes when i check are executing the select @@max_process procedure.

After investigating theese i realised it was the services running the applications that were running these processes. Then i stop the processes and put tthe database in single user mode again. This time it all works
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-11-06 : 07:21:10
Also: make sure your process is not connected to the database you want to restore!

Kristen
Go to Top of Page
   

- Advertisement -