Yesterday and friends on the Internet talking about the application of SQL statements, my friend's remote server appears to be unable to connect the phenomenon, the problem is due to the remote server reached the maximum number of connections, in order to achieve remote reboot, so that the use of SQL Statement command to implement this function, but the specific command format to forget, find some information, Write the method down below,
I hope we can give you some help, hehe
First on the local computer--Create a restart script
Copy Code code as follows:
DECLARE @o int,@f int,@t int, @ret int
exec sp_oacreate ' Scripting.FileSystemObject ', @o out
exec sp_OAMethod @o, ' CreateTextFile ', @f out, ' C:\restart.bat ', 1
EXEC @ret =sp_oamethod @f, ' WriteLine ', NULL, ' net stop MSSQLServer '
EXEC @ret =sp_oamethod @f, ' WriteLine ', NULL, ' net start mssqlserver '
Connecting to a remote server through a SQL database--performing a restart script
EXEC master.. xp_cmdshell ' C:\restart.bat '
/*
If you restart your computer, confirm that the MSSQLServer account is running under the Administrator account (non-local System account)
*/
EXEC master.. xp_cmdshell ' shutdown/r/F '
Here is the premise, that is, need to use a component on the server, xp_cmdshell this component, but the general server,
This component is disabled. So you have to use the component before you can apply the above method.