@@SERVICENAME (Transact-SQL)

**APPLIES TO:** ![yes](media/yes.png)SQL Server (starting with 2008) ![yes](media/yes.png)Azure SQL Database (Managed Instance only) ![no](media/no.png)Azure SQL Data Warehouse ![no](media/no.png)Parallel Data Warehouse

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.

Topic link icon 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 is the result set.

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

See Also

Configuration Functions (Transact-SQL)
Manage the Database Engine Services