The remote server reached the maximum number of connections, in order to achieve a remote restart, so think of the SQL Statement command to implement this function, but the specific command format to forget, found a little information tutorial . net/c# course [4]:sqlserver Basic application Development , the method is written below, I hope we can give you some help it, hehe.
first on the local computer--Create a restart script
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 via SQL database--performing a restart script
exec master. xp_cmdshell ' C:/restart.bat '
/*
If you restart your computer, make sure that the MSSQLServer account is running under the Administrator account (not the local System account)
*/
exec master. xp_cmdshell ' shutdown/r/F '
Here is a premise, it is necessary to use a component on the server, xp_cmdshell this component, but the general server,
this component is disabled. Therefore, you must first use the component before you can apply the above method.
This article is from the "Add Language" blog, please make sure to keep this source http://yuguotianqing.blog.51cto.com/9292883/1572804
SQL Server restarts servers and other operations