Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Restart a Computer in SQL?

Status
Not open for further replies.

Andel

Programmer
Feb 15, 2001
366
US
Is there a way I can restart my computer(sql server) using query analyzer or the sql agent?

Thanks for your help.

Andel

Andel
andelbarroga@hotmail.com
 
from a dos prompt you can:

net stop mssqlserver

then

net start mssqlserer


you could put this in a bat file and execute with a pause in between from 'at' or even possibly the mssql scheduler..... Paul
 
Hi Paul... thanks for responding.
What I really need is to "reboot" the server, not only to restart. Any idea?

Thanks.

Andel Andel
andelbarroga@hotmail.com
 
Call:
xp_cmdshell "Shutdownprogram.exe"
If you don't have a shutdown program you can make one in VB or in VC.Let me know if you need such a program.(max 30kb)

Hope this helps you,s-)
Blessed is he who in the name of justice and good will, shepards the week through the valley of darknees...
 
Hi BurtanI,

Thanks for responding. Shutdown will not bring the computer back up automatically. I need a "reboot or restart" so that when the computer comes back up, sql server will come back up as well. Any other idea?

Thanks,

Andel
andelbarroga@hotmail.com
 
Hi Paul,

I was going to ask this question in the NT forum but I want to use SQL command to restart the computer.

Andel
andelbarroga@hotmail.com
 
You can run any old piece of crap from SQL (using xp_cmdshell "Shutdownprogram.exe" as shown by BurtanI above), if you can find out how you restart the server then you can make a little program to do it.

I've got the VB code to do it, I'll send it.
HF
 
Hi hellferret.

I received the vb code you sent. Thanks a lot. It works very well!



Andel
andelbarroga@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top