| title | @@SERVICENAME (Transact-SQL) | Microsoft Docs | |||
|---|---|---|---|---|
| ms.custom | ||||
| ms.date | 03/14/2017 | |||
| ms.prod | sql-non-specified | |||
| ms.reviewer | ||||
| ms.suite | ||||
| ms.technology |
|
|||
| ms.tgt_pltfrm | ||||
| ms.topic | language-reference | |||
| f1_keywords |
|
|||
| dev_langs |
|
|||
| helpviewer_keywords |
|
|||
| ms.assetid | 5b0b35be-50ae-411d-a607-bf7464b73624 | |||
| caps.latest.revision | 23 | |||
| author | BYHAM | |||
| ms.author | rickbyh | |||
| manager | jhubbard |
[!INCLUDEtsql-appliesto-ss2008-xxxx-xxxx-xxx_md]
Returns the name of the registry key under which [!INCLUDEssNoVersion] 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.
Transact-SQL Syntax Conventions
@@SERVICENAME
nvarchar
[!INCLUDEssNoVersion] runs as a service named MSSQLServer.
The following example shows using @@SERVICENAME.
SELECT @@SERVICENAME AS 'Service Name';
[!INCLUDEssResult]
Service Name
------------------------------
MSSQLSERVER
Configuration Functions (Transact-SQL)
Manage the Database Engine Services