Obtain the SQL SERVER service status and the enabled Protocol

Source: Internet
Author: User

1. Obtain the SQL SERVER service startup status through the registry. It is the same as obtaining the startup status of other services. The method is to find the Start key value in the Registry: HK_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ {service name. The value indicates:

  • 2 indicates Automatic)
  • 3 indicates Manual)
  • 4 indicates disabled (Diabled)

2. Get or set the startup status of SqlServer.
You can use the System. ServiceProcess. ServiceController class to obtain or set the service status.

3. Obtain or set the protocol enabled by Sqlserver.
Sqlserver provides four Protocols: sharemememory, Named Pipe, Tcp, and.
You can also query the registry to determine whether a protocol is enabled. The following example shows whether the Tcp protocol under SqlExpress is enabled.

  • Generally, each SQL server Instance has a key under HK_LOCAL_MACHINE \ Software \ Microsoft SQL Server \ Instance \ SQL. Obtain the value of the SQLEXPRESS key in this directory. Assume MSSQL.1.
  • Go to HK_LOCAL_MACHINE \ Software \ Microsoft SQL Server \ MSSQL.1 \ MSSQLServer \ SuperSocketNetLib and you can see that each of the four directories represents a protocol. Among them, Np represents Named Pipe, Sm represents Shared Memory, and the other two are Tcp and.
  • View the value of the Enabled key under Tcp. If the value is 1, the Protocol is enabled, and 0 indicates that the Protocol is disabled.
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.