Start the SQL Server service with bat

Source: Internet
Author: User
Tags mssqlserver

The statement under this script is not I write, forget where to see from, here to share to everyone, because in my understanding technology is used to share, I hope the original author see not mind.

1. Create a text to change the suffix name to. bat

2. Paste the bottom statement in, then save

@echo off
for/f "Skip=3 tokens=4"%%i in (' sc query MSSQLSERVER ') do set "zt=%%i" &goto:next

: Next
if/i "%zt%" = = "RUNNING" (
Echo has found that the service is running and starts to stop
net stop MSSQLSERVER
Echo sc config MSSQLSERVER start = DISABLED Disable Service
) Else (
echo the service now handles the stop state and starts to start
Echo sc config MSSQLSERVER start = Manual Set service manual
net start MSSQLSERVER
)

Pause

Note that the ' MSSQLSERVER ' is the default instance name for SQL Server, and if you have more than one instance on your servers, you will need to manually replace the service name in the script.

Start the SQL Server service with bat

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.