Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

@@SERVICENAME (Transact-SQL)

Applies to: 👁 Image
SQL Server 👁 Image
Azure SQL Managed Instance

Returns the name of the registry key under which SQL Server is running. @@SERVICENAME returns 'MSSQLSERVER' if the current instance is the default instance; this function returns the instance name if the current instance is a named instance.

👁 Image
Transact-SQL syntax conventions

Syntax

@@SERVICENAME 

Return Types

nvarchar

Remarks

SQL Server runs as a service named MSSQLServer.

Examples

The following example shows using @@SERVICENAME.

SELECT @@SERVICENAME AS 'Service Name'; 

Here's the result set.

Service Name 
------------------------------ 
MSSQLSERVER 

See Also

Manage the Database Engine Services


Feedback

Was this page helpful?

Additional resources