[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.sqlserver.programming

Can u restart sql server using a SqlQuery ??

Hadidi

3/20/2007 1:23:00 PM

I'm changing sql server configuration using a sql query .. these changes
needs restarting the server .
So .. Is it possible to restart the server , & how ??

Thanks
4 Answers

Immy

3/20/2007 2:45:00 PM

0

Cant say if there is a 'restart sql' command in 2005, but previous versions
only allow the SHUTDOWN command which will stop the service but not restart
it.

The issue with issuing a restart command via SQL is that at the point the
service is stopped, you no longer have a connection to the server to issue
the Restart.

You could try creating a batch file with the NET STOP and NET START commands
and then call the batch file from xp_cmdshell?

Immy


"Hadidi" <Hadidi@discussions.microsoft.com> wrote in message
news:75F1532A-B76B-44C6-8647-A1BCBAF5FEB8@microsoft.com...
> I'm changing sql server configuration using a sql query .. these changes
> needs restarting the server .
> So .. Is it possible to restart the server , & how ??
>
> Thanks


CLM

3/20/2007 5:15:00 PM

0

You can't use xp_cmdshell once the service is down...You've got to go through
the o/s exclusively.

"Immy" wrote:

> Cant say if there is a 'restart sql' command in 2005, but previous versions
> only allow the SHUTDOWN command which will stop the service but not restart
> it.
>
> The issue with issuing a restart command via SQL is that at the point the
> service is stopped, you no longer have a connection to the server to issue
> the Restart.
>
> You could try creating a batch file with the NET STOP and NET START commands
> and then call the batch file from xp_cmdshell?
>
> Immy
>
>
> "Hadidi" <Hadidi@discussions.microsoft.com> wrote in message
> news:75F1532A-B76B-44C6-8647-A1BCBAF5FEB8@microsoft.com...
> > I'm changing sql server configuration using a sql query .. these changes
> > needs restarting the server .
> > So .. Is it possible to restart the server , & how ??
> >
> > Thanks
>
>
>

rpresser

3/20/2007 9:21:00 PM

0

On Mar 20, 1:15 pm, CLM <C...@discussions.microsoft.com> wrote:
> You can't use xp_cmdshell once the service is down...You've got to go through
> the o/s exclusively.
>

See below.

@echo off
rem if no arguments, start myself with an argument
if .%1 ==. (
START /NOWAIT cmd.exe /c %0 NESTED
GOTO :EOF
)

rem wait 10 seconds to let xp_Cmdshell settle down
ping -n 10 127.0.0.1 >nul

rem stop the sql service
net stop mssql

rem wait another 10 seconds
ping -n 10 127.0.0.1 >nul

rem start the sql service
net start mssql


PATRICK

2/7/2013 12:50:00 PM

0

Free Lunch <lunch@nofreelunch.us> wrote:

>The RCC is an enemy of civilization.

<yawn>