In this blog, we will simply show how to get the full SQL Server Instance Name using "SERVERPROPERTY"
What's the "SERVERPROPERTY"?
"SERVERPROPERTY" is a System-defined Function used to return the SQL Server instance information.
"SERVERPROPERTY" Syntax
- SERVERPROPERTY ('propertyname')
SERVERNAME
Use SERVERNAME property to get the full SQL Server instance name.
Example
- Select SERVERPROPERTY('servername') as 'Server Name'.
Output
SERVERINSTANCE
Use SERVERINSTANCE property to get the SQL Server instance name to which the user is connected.
Example
- Select SERVERPROPERTY('serverinstance') as 'Server Name'
Output
Applies To
- SQL Server 2008.
- SQL Server 2012.
- SQL Server 2014.
- SQL Server 2016.
- SQL Server 2017.
Reference
See Also