In SQL Server, the @@SERVICENAME
configuration function returns the name of the registry key under which SQL Server is running.
No argument is required. You can simply use it in a SELECT
statement to return the registry key’s name.
Note that SQL Server runs as a service named MSSQLServer. The @@SERVICENAME
function returns MSSQLSERVER if the current instance is the default instance. It returns the instance name if the current instance is a named instance.