SQL Server | SERVERPROPERTY()

05 Aug, 2020
SQL Server provides a System Defined function SERVERPROPERTY(propertyname). 
SERVERPROPERTY(): SERVERPROPERTY() function is used to return the information about different properties of system or so called the instance information. 
propertyname: This expression contains the information about property in question and returns the same. 
Following are few property names which SERVERPROPERTY() function provides information about. Apart from mentioned properties there are other properties too. 
1. MachineName: This property name is used as an argument in SERVERPROPERTY() function to find the name of the machine/computer on which SQL Server is running. 
Syntax:  
SELECT SERVERPROPERTY ('MachineName')


Example:  
Output:  
2. Edition: This property name is used an argument in SERVERPROPERTY() function to get the edition of SQL Server installed on machine/computer. 
Syntax:  
SELECT SERVERPROPERTY ('Edition')


Example:  
3. INSTANCEDEFAULTDATAPATH: This property name is used as an argument in SERVERPROPERTY() function to find the default path of the data files. 
Syntax:  
SELECT SERVERPROPERTY ('INSTANCEDEFAULTDATAPATH')


Example:  
4. INSTANCEDEFAULTLOGPATH: This property name is used as an argument in SERVERPROPERTY() function to find the default path of the log files. 
Syntax:  
SELECT SERVERPROPERTY ('INSTANCEDEFAULTLOGPATH')


Example:  
5. PRODUCTVERSION: This property name is used as an argument in SERVERPROPERTY() function to get the information about the version of product being used. 
Syntax:  
SELECT SERVERPROPERTY (' PRODUCTVERSION')


Example:  
6. BUILDCLRVERSION: This property name is used as an argument in SERVERPROPERTY() function to get the information about the version of the Microsoft .NET Framework Common Language Runtime (CLR). This framework was used for building the SQL Server instance. 
Syntax:  
SELECT SERVERPROPERTY ('BUILDCLRVERSION')


Example:  
7. PROCESSID: This property name is used as an argument in SERVERPROPERTY() function to get the Process ID of the SQL Server service. 
Syntax:  
SELECT SERVERPROPERTY ('PROCESSID')


Example:  
8. ResourceLastUpdateDateTime: This property name is used as an argument in SERVERPROPERTY() function to get the information about the last updates of the Resource Database i.e the Date and Time when the Resource Database was last updated on. 
Syntax:  
SELECT SERVERPROPERTY ('ResourceLastUpdateDateTime')


Example:  
9. EditionID: This property name is used as an argument in SERVERPROPERTY() function to find the Edition ID of the SQL Server being installed on computer/machine. 
Syntax:  
SELECT SERVERPROPERTY ('EditionID')


Example:  
10. Collation: This property name is used as an argument in SERVERPROPERTY() function to find the collation of the SQL Server being installed on computer/machine. 
Syntax:
select SERVERPROPERTY ('collation')
Example: 
Note: To get the information about other properties, refer Microsoft Docs. 
khushboogoyal499
SQL-Server
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Update Multiple Columns in Single Update Statement in SQL?
Window functions in SQL
What is Temporary Table in SQL?
SQL using Python
SQL | Sub queries in From Clause
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
RANK() Function in SQL Server
SQL Query to Convert VARCHAR to INT
SQL Query to Compare Two Dates
SQL Query to Insert Multiple Rows