Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

My SQL Server's instance name is SQLEXPRESS and SQL Server Service Name looks like MSSQL$SQLEXPRESS. Is there any relation between instance name and service name? I'm trying to check SQL Server Service Status by name and I wonder can SQL Server Service name be different on another computers?

share|improve this question

2 Answers 2

up vote 10 down vote accepted

Yes, the service name is always MSSQL$<Instance Name> for a named instance and MSSQLSERVER for a default instance. I don't believe either can be altered or overridden, nor can I think of any reason why you'd want to.

You can enumerate the installed instances on a server via the registry, using Powershell for example:

Get-ItemProperty 'HKLM:\Software\Microsoft\Microsoft SQL Server\Instance Names\SQL'
share|improve this answer
1  
+1 on your answer. I've added another answer to show a second way to get the desired information on service states. –  Thomas Stringer Jan 3 at 18:59

Mark showed you a way to get this information directly from the registry, but another way to do this would be through WMI, consumed by PowerShell:

Get-WmiObject -ComputerName "YourDestinationServer" -Namespace "root\microsoft\sqlserver\computermanagement11" -Class "SqlService" |
    Where-Object {$_.SQLServiceType -eq 1} |
    Select-Object ServiceName, DisplayName, 
        @{Name = "StateDesc"; Expression = {
            switch ($_.State) {
                1 { "Stopped" }
                2 { "Start Pending" }
                3 { "Stop Pending" }
                4 { "Running" }
                5 { "Continue Pending" }
                6 { "Pause Pending" }
                7 { "Paused" }
            }
        }}

The above command will give you the state of the SQL Server engine service(s) on a particular machine.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.