In this article, we will explain how to Get SQL Server info using SERVERPROPERTY, we will also provide a complete SQL Query to get all detailed information of the current installed SQL Server, like version, instance name, build number …etc.
- 1 What’s the SERVERPROPERTY in SQL Server?
-
2
Get SQL Server Info Using SERVERPROPERTY()
- 2.1 How to get the Machine Name in SQL Server?
- 2.2 How to Get SQL Server Version using @@Version?
- 2.3 How to get Computer Name Physical Net BIOS in SQL Server?
- 2.4 How to get full SQL Server Instance Name?
- 2.5 How to get SQL Server Instance Name?
- 2.6 How to get default data files path in SQL Server?
- 2.7 How to get SQL Server Edition?
- 2.8 How to get SQL Server Edition ID and its corresponding name?
- 2.9 How to get SQL Server Product Build?
- 2.10 How to get SQL Server Product Build Type?
- 2.11 How to get SQL Server Product Version Level?
- 2.12 How to get SQL Server Build Number?
- 2.13 How to get SQL Server Product Version Minor Level?
- 2.14 How to get the current Cumulative update installed in SQL Server?
- 2.15 How to get the version of the Microsoft .NET Framework in SQL Server?
- 2.16 How to get Collation Name in SQL Server?
- 2.17 How to get locale identifier in SQL Server?
- 2.18 How to if the Server is in single-user mode in SQL Server?
- 2.19 How to check if the security mode in SQL Server?
- 2.20 How to check Always On availability Status in SQL Server?
- 2.21 How to check the status of the Always On availability groups manager in SQL Server?
- 2.22 How to check if the Advanced Analytics is installed in SQL Server?
- 2.23 How to get Process ID of SQL Server Service?
- 2.24 How to get SQL Server Instance Information Remotely?
Download the full SQL Query from GitHub at Get The Detailed SQL Server Information.
What’s the SERVERPROPERTY in SQL Server?
SERVERPROPERTY is a System Defined function used to return the SQL Server Instance Information.
SERVERPROPERTY Syntax
SERVERPROPERTY ('propertyname')
SERVERPROPERTY Values
“propertyname“ is one of the following values.
- MachineName.
- ComputerNamePhysicalNetBIOS.
- ServerName.
- InstanceName.
- InstanceDefaultDataPath.
- InstanceDefaultLogPath.
- Edition.
- EditionID.
- EngineEdition.
- ProductBuild.
- ProductBuildType.
- ProductLevel.
- ProductMajorVersion.
- ProductMinorVersion.
- ProductUpdateLevel.
- ProductVersion.
- BuildClrVersion.
- Collation.
- LCID.
- IsSingleUser.
- IsIntegratedSecurityOnly.
- IsHadrEnabled.
- HadrManagerStatus.
- IsAdvancedAnalyticsInstalled.
- IsClustered.
- IsFullTextInstalled.
- ProcessID.
Get SQL Server Info Using SERVERPROPERTY()
In this section, we will explore the most common used SERVERPROPERTY in SQL Server.
How to get the Machine Name in SQL Server?
MachineName is a Server Property that used to get the computer name on which the SQL server instance is running.
Example
select SERVERPROPERTY('MachineName') as 'MachineName'
For the cluster, it returns the virtual server name.
Applies To
- SQL Server 2008.
- SQL Server 2012.
- SQL Server 2014.
- SQL Server 2016.
- SQL Server 2017.
How to Get SQL Server Version using @@Version?
Actually, @@Version is not a server property, but it’s an easy way to get the version name and build number.
Example
select @@version as 'Version'
Applies To
- SQL Server 2008.
- SQL Server 2012.
- SQL Server 2014.
- SQL Server 2016.
- SQL Server 2017.
You might also like to read How to Get SQL Server Build Numbers?
How to get Computer Name Physical Net BIOS in SQL Server?
ComputerNamePhysicalNetBIOS is a Server Property that used to get the NetBIOS name of the local computer on which the SQL server instance is running.
Example
select SERVERPROPERTY('ComputerNamePhysicalNetBIOS') as 'ComputerName PhysicalNetBIOS'
Applies To
- SQL Server 2008.
- SQL Server 2012.
- SQL Server 2014.
- SQL Server 2016.
- SQL Server 2017.
How to get full SQL Server Instance Name?
ServerName is a Server Property that used to get the full SQL Server instance name.
Example
select SERVERPROPERTY('ServerName') as 'Server Name'
Applies To
- SQL Server 2008.
- SQL Server 2012.
- SQL Server 2014.
- SQL Server 2016.
- SQL Server 2017.
How to get SQL Server Instance Name?
InstanceName is a Server Property that used to only get the instance name without the domain name.
Example
select SERVERPROPERTY('InstanceName') as 'InstanceName'
Applies To
- SQL Server 2008.
- SQL Server 2012.
- SQL Server 2014.
- SQL Server 2016.
- SQL Server 2017.
How to get default data files path in SQL Server?
InstanceDefaultDataPath is a Server Property that used to get the default path of data files.
Example
select SERVERPROPERTY('InstanceDefaultDataPath') as 'Data Path'
Applies To
- SQL Server 2012 through the current version of updates beginning in late 2015.
- SQL Server 2014.
- SQL Server 2016.
- SQL Server 2017.
How to get default log files path in SQL Server?
InstanceDefaultLogPath is a Server Property that used to get the default path of log files.
Example
select SERVERPROPERTY('InstanceDefaultLogPath') as 'Log Path'
Applies To
- SQL Server 2012 through the current version of updates beginning in late 2015.
- SQL Server 2014.
- SQL Server 2016
- SQL Server 2017.
How to get SQL Server Edition?
Edition is a Server Property that used to get the Installed product edition.
Example
select SERVERPROPERTY('Edition') as 'Edition'
Applies To
- SQL Server 2008.
- SQL Server 2012.
- SQL Server 2014.
- SQL Server 2016.
- SQL Server 2017.
How to get SQL Server Edition ID and its corresponding name?
EditionID is a Server Property that used to get the Installed product edition ID.
Example
declare @EditionID as sql_variant
set @EditionID= (select SERVERPROPERTY('EditionID'))
select @EditionID as EditionID,
case @EditionID
when -1534726760 then 'Standard'
when 1804890536 then 'Enterprise'
when 1872460670 then 'Enterprise Edition: Core-based Licensing'
when 610778273 then 'Enterprise Evaluation'
when 284895786 then 'Business Intelligence'
when -2117995310 then 'Developer'
when -1592396055 then 'Express'
when -133711905 then 'Express with Advanced Services'
when 1293598313 then 'Web'
when 1674378470 then 'SQL Database or SQL Data Warehouse'
end as 'Edition Based on ID'
Applies To
- SQL Server 2008.
- SQL Server 2012.
- SQL Server 2014.
- SQL Server 2016.
- SQL Server 2017.
How to get SQL Server Engine Edition?
EngineEdition is a Server Property that used to get the Database Engine edition.
Example
declare @EngineEdition as sql_variant
set @EngineEdition = (select SERVERPROPERTY('EngineEdition'))
select @EngineEdition as EngineEdition,
case @EngineEdition
when 1 then 'Personal or Desktop Engine'
when 2 then 'Standard'
when 3 then 'Enterprise'
when 4 then 'Express'
when 5 then ' SQL Database'
when 6 then 'SQL Data Warehouse'
end as 'Engine Edition Based on ID'
Applies To
- SQL Server 2008.
- SQL Server 2012.
- SQL Server 2014.
- SQL Server 2016.
- SQL Server 2017.
How to get SQL Server Product Build?
ProductBuild is a Server Property that used to get the build number.
Example
select SERVERPROPERTY('ProductBuild') as 'ProductBuild'
Applies To
- SQL Server 2014 beginning October 2015,
- SQL Server 2016.
- SQL Server 2017.
How to get SQL Server Product Build Type?
ProductBuildType is a Server Property that used to get the type of build name.
Example
declare @ProductBuildType as sql_variant
set @ProductBuildType = (select SERVERPROPERTY('ProductBuildType'))
select @ProductBuildType as ProductBuildType,
case @ProductBuildType
when 'OD' then 'On Demand release'
when 'GDR' then 'General Distribution Release'
else 'Not applicable'
end as 'ProductBuild Type'
Applies To
- SQL Server 2012 through the current version of updates beginning in late 2015.
- SQL Server 2014.
- SQL Server 2016.
- SQL Server 2017.
How to get SQL Server Product Version Level?
ProductLevel is a Server Property that used to get the version level as
- ‘RTM’ = Original release version
- ‘SPn‘ = Service pack version
- ‘CTPn‘, = Community Technology Preview version
Example
select SERVERPROPERTY('ProductMajorVersion') as 'ProductMajor Version'
Applies To
- SQL Server 2008.
- SQL Server 2012.
- SQL Server 2014.
- SQL Server 2016.
- SQL Server 2017.
How to get SQL Server Build Number?
ProductVersion is a Server Property that used to get the product version as major.minor.build.revision.
Applies To
- SQL Server 2008.
- SQL Server 2012.
- SQL Server 2014.
- SQL Server 2016.
- SQL Server 2017.
Example
select SERVERPROPERTY('ProductVersion') as 'Product Version'
You might also like to read How to Get SQL Server Build Numbers?
How to get SQL Server Product Version Minor Level?
ProductMinorVersion is a Server Property that used to get the minor version.
Example
select SERVERPROPERTY('ProductMinorVersion') as 'ProductMinor Version'
Applies To
- SQL Server 2012 through the current version of updates beginning in late 2015.
- SQL Server 2014.
- SQL Server 2016.
- SQL Server 2017.
How to get the current Cumulative update installed in SQL Server?
ProductUpdateLevel is a Server Property that used to get the current Cumulative update installed name as CUn.
Example
select SERVERPROPERTY('ProductUpdateLevel') as 'ProductUpdate Level'
You might also like to read SQL Server: How to get the current installed update level
Applies To
- SQL Server 2012 through the current version of updates beginning in late 2015.
- SQL Server 2014.
- SQL Server 2016.
- SQL Server 2017.
How to get the version of the Microsoft .NET Framework in SQL Server?
BuildClrVersion is a Server Property that used to get the version of the Microsoft .NET Framework common language runtime (CLR) that was used while building the instance of SQL Server.
Example
select SERVERPROPERTY('BuildClrVersion') as 'BuildClr Version'
Applies To
- SQL Server 2008.
- SQL Server 2012.
- SQL Server 2014.
- SQL Server 2016.
- SQL Server 2017.
How to get Collation Name in SQL Server?
Collation is a Server Property that used to get the name of the default collation for the server.
Example
select SERVERPROPERTY('Collation') as 'Collation'
Applies To
- SQL Server 2008.
- SQL Server 2012.
- SQL Server 2014.
- SQL Server 2016.
- SQL Server 2017.
How to get locale identifier in SQL Server?
LCID is a Server Property that used to get the locale identifier (LCID) of the collation.
Example
select SERVERPROPERTY('LCID') as 'LCID'
Applies To
- SQL Server 2008.
- SQL Server 2012.
- SQL Server 2014.
- SQL Server 2016.
- SQL Server 2017.
How to if the Server is in single-user mode in SQL Server?
IsSingleUser is a Server Property that used to check if the Server is in single-user mode.
Example
declare @IsSingleUser as sql_variant
set @IsSingleUser = (select SERVERPROPERTY('IsSingleUser'))
select @IsSingleUser as IsSingleUserID,
case @IsSingleUser
when 0 then 'Multiple User'
when 1 then 'Single user'
else 'Invalid Input'
end as 'IsSingleUser'
Applies To
- SQL Server 2008.
- SQL Server 2012.
- SQL Server 2014.
- SQL Server 2016.
- SQL Server 2017.
How to check if the security mode in SQL Server?
IsIntegratedSecurityOnly is a Server Property that used to check the integrated security mode.
Example
declare @IsIntegratedSecurityOnly as sql_variant
set @IsIntegratedSecurityOnly = (select SERVERPROPERTY('IsIntegratedSecurityOnly'))
select @IsIntegratedSecurityOnly as IsIntegratedSecurityOnly,
case @IsIntegratedSecurityOnly
when 0 then 'Windows and SQL Server Authentication'
when 1 then ' Integrated security (Windows Authentication)'
else 'Invalid Input'
end as 'Integrate dSecurity Type'
Applies To
- SQL Server 2008.
- SQL Server 2012.
- SQL Server 2014.
- SQL Server 2016.
- SQL Server 2017.
How to check Always On availability Status in SQL Server?
IsHadrEnabled is a Server Property that used to check Always On availability groups is enabled or disabled.
Applies To
- SQL Server 2012.
- SQL Server 2014.
- SQL Server 2016.
- SQL Server 2017.
Example
declare @IsHadrEnabled as sql_variant
set @IsHadrEnabled = (select SERVERPROPERTY('IsHadrEnabled'))
select @IsHadrEnabled as IsHadrEnabled,
case @IsHadrEnabled
when 0 then 'The Always On availability groups is disabled'
when 1 then 'The Always On availability groups is enabled'
else 'Invalid Input'
end as 'Hadr'
How to check the status of the Always On availability groups manager in SQL Server?
HadrManagerStatus is a Server Property that used to check the Always On availability groups manager status.
Example
declare @HadrManagerStatus as sql_variant
set @HadrManagerStatus = (select SERVERPROPERTY('HadrManagerStatus'))
select @HadrManagerStatus as HadrManagerStatus,
case @HadrManagerStatus
when 0 then 'Not started, pending'
when 1 then 'Started and running'
when 2 then 'Not started and failed'
else 'Invalid Input'
end as 'HadrManager Status'
Applies To
- SQL Server 2012.
- SQL Server 2014.
- SQL Server 2016.
- SQL Server 2017.
How to check if the Advanced Analytics is installed in SQL Server?
IsAdvancedAnalyticsInstalled is a Server Property that used to check the Advanced Analytics status.
Example
declare @IsAdvancedAnalyticsInstalled as sql_variant
set @IsAdvancedAnalyticsInstalled = (select SERVERPROPERTY('IsAdvancedAnalyticsInstalled'))
select @IsAdvancedAnalyticsInstalled as IsAdvancedAnalyticsInstalled ,
case @IsAdvancedAnalyticsInstalled
when 0 then 'Advanced Analytics was not installed'
when 1 then 'Advanced Analytics was installed'
else 'Invalid Input'
end as 'AdvancedAnalyticsInstalled Status'
Applies To
- SQL Server 2016.
- SQL Server 2017.
How to check if if the failover cluster is configured or not in SQL Server?
IsClustered is a Server Property that used to check if the failover cluster is configured or not.
Example
declare @IsClustered as sql_variant
set @IsClustered = (select SERVERPROPERTY('IsClustered'))
select @IsClustered as IsClustered ,
case @IsClustered
when 0 then 'Not Clustered'
when 1 then 'Clustered'
else 'Invalid Input'
end as 'IsClustered Status'
Applies To
- SQL Server 2008.
- SQL Server 2012.
- SQL Server 2014.
- SQL Server 2016.
- SQL Server 2017.
How to check if the full text installed or not in SQL Server?
IsFullTextInstalled is a Server Property that used to check if The full-text and semantic indexing components are installed or not.
Example
declare @IsFullTextInstalled as sql_variant
set @IsFullTextInstalled = (select SERVERPROPERTY('IsFullTextInstalled'))
select @IsFullTextInstalled as IsFullTextInstalled ,
case @IsFullTextInstalled
when 0 then 'Full-text and semantic indexing components are not installed'
when 1 then 'Full-text and semantic indexing components are installed'
else 'Invalid Input'
end as 'IsFullTextInstalled Status'
Applies To
- SQL Server 2008, 2012 ,2014,2016,2017.
How to get Process ID of SQL Server Service?
ProcessID is a Server Property that used to get the Process ID of the SQL Server service.
Example
select SERVERPROPERTY('ProcessID') as 'ProcessID'
Applies To
- SQL Server 2008.
- SQL Server 2012.
- SQL Server 2014.
- SQL Server 2016.
- SQL Server 2017.
How to get SQL Server Instance Information Remotely?
You can use Windows PowerShell to invoke SQL command on a reachable server within the network using Invoke-Sqlcmd cmdlet as the following:
- Open Windows PowerShell as Administrator
- Type the Invoke-Sqlcmd with the below parameters.
- -query: the SQL query that you need to run on the remote server.
- -ServerInstance: the SQL server instance name.
- -Username: the username that has sufficient permission to access and execute SQL query on the remote server.
- -Password: the password of the elevated user.
Example
Invoke-Sqlcmd -query "select SERVERPROPERTY('MachineName') as 'MachineName'" -ServerInstance "epm\epmdb" -Username sa -Password *****
Reference
- SERVERPROPERTY (Transact-SQL)
- Published by me in Microsoft TechNet Wiki at T-SQL: Get SQL Server Instance Information Using SERVERPROPERTY. however, you can find the latest updates and more details in this post.
Download
- Download the full query from GitHub at Get The Detailed SQL Server Information.