SQL Server | SERVERPROPERTY()

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:

Note: To get the information about other properties, refer Microsoft Docs.



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.