Skip to content

Latest commit

 

History

History
72 lines (58 loc) · 2.28 KB

File metadata and controls

72 lines (58 loc) · 2.28 KB

title: "@@SERVICENAME (Transact-SQL) | Microsoft Docs" ms.custom: "" ms.date: "09/18/2017" ms.prod: "sql" ms.prod_service: "sql-database" ms.service: "" ms.component: "t-sql|functions" ms.reviewer: "" ms.suite: "sql" ms.technology:

  • "database-engine" ms.tgt_pltfrm: "" ms.topic: "language-reference" f1_keywords:
  • "@@SERVICENAME_TSQL"
  • "@@SERVICENAME" dev_langs:
  • "TSQL" helpviewer_keywords:
  • "@@SERVICENAME function"
  • "names [SQL Server], registry keys"
  • "registry keys [SQL Server]" ms.assetid: 5b0b35be-50ae-411d-a607-bf7464b73624 caps.latest.revision: 23 author: "edmacauley" ms.author: "edmaca" manager: "craigg" ms.workload: "Inactive" monikerRange: "= azuresqldb-mi-current || >= sql-server-2016 || = sqlallproducts-allversions"

@@SERVICENAME (Transact-SQL)

[!INCLUDEtsql-appliesto-ss2008-asdbmi-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.

[!INCLUDEssMIlimitation]

Topic link icon Transact-SQL Syntax Conventions

Syntax

@@SERVICENAME  

Return Types

nvarchar

Remarks

[!INCLUDEssNoVersion] runs as a service named MSSQLServer.

Examples

The following example shows using @@SERVICENAME.

SELECT @@SERVICENAME AS 'Service Name';  

[!INCLUDEssResult]

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

See Also

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