To start the SQL Server service bat script sharing _mssql

Source: Internet
Author: User
Tags mssqlserver

This script is not written by me, I forget where I saw it, share it with you, because in my understanding technology is used to share, hope the original author see Don't mind.

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

2. Paste the bottom statement in, and then save it

Copy Code code as follows:

@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 discovered 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
Echo SC config mssqlserver start = Manual Set service manual
NET start MSSQLServer
)

Pause


The place to note is ' MSSQLServer ', which is the default instance name for SQL Server, and if you have multiple instances on your servers, you need to manually replace the service name in the script.

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.