You can use xp_cmdshell system procedure to call any command line to stop; however, you definitely can't start it because how will you execute a command using T-SQL while you are not connected (service is stopped)?
You can't directly start or stop SQL Server itself using SQL statements, you can perform tasks related to database management, such as starting, stopping, and restarting individual databases within SQL Server using SQL statements.
4条答案
按热度按时间gojuced71#
Actually you can't do this from the SQL statement, but you can perform this with the powershell/cmd
km0tfn4u2#
You can use
xp_cmdshell
system procedure to call any command line to stop; however, you definitely can't start it because how will you execute a command using T-SQL while you are not connected (service is stopped)?8yoxcaq73#
using the command line or powershell .
net start MSSQL$instancename
net stop MSSQL$instance
using SSMS
SHUTDOWN
-->wait and shutdownSHUTDOWN WITH NOWAIT
--> dont wait and shutdownDon't think there is a straight way you can startup in T-SQL, you probably have to do something like this.
z9smfwbn4#
You can't directly start or stop SQL Server itself using SQL statements, you can perform tasks related to database management, such as starting, stopping, and restarting individual databases within SQL Server using SQL statements.