The Little Known Secrets of T-SQL SERVERPROPERTY Function

Ok, you walk into this new customer site that you just picked up as a result of a change of VAR. You know nothing about their SQL Server installation and/or whether it is properly configured with all the required service packs. How would you like to be able to pull a bunch of SQL Server information without having to search the entire Internet for it, or search the entire SQL Server Books Online help file, bother the DBA, or better yet, call me :-).

T-SQL has a very little known function called SERVERPROPERTY which provides a vast number of arguments that allow you to obtain tremendous amount of information about your SQL Server. The following is a list of my favorite propterties and the most requested by consultants, DBAs, and users alike:

Syntax

SERVERPROPERTY (propertyname)

Properties

  • Collation: returns the name of the default collation being used on your SQL Server
  • Edition: Installed product edition of the instance of SQL Server. Use the value of this property to determine the features and the limits, such as maximum number of CPUs, that are supported by the installed product.
    Returns:
    'Desktop Engine' (Not available for SQL Server 2005.)
    'Developer Edition'
    'Enterprise Edition'
    'Enterprise Evaluation Edition'
    'Personal Edition'(Not available for SQL Server 2005.)
    'Standard Edition'
    'Express Edition'
    'Express Edition with Advanced Services'
    'Workgroup Edition'
    'Windows Embedded SQL'
  • EngineEdition: Database Engine edition of the instance of SQL Server installed on the server.
    1 = Personal or Desktop Engine (Not available for SQL Server 2005.)
    2 = Standard (This is returned for Standard and Workgroup.)
    3 = Enterprise (This is returned for Enterprise, Enterprise Evaluation, and Developer.)
    4 = Express (This is returned for Express, Express Edition with Advanced Services, and Windows Embedded SQL.)
  • InstanceName: Name of the instance to which the user is connected. Returns NULL if the instance name is the default instance, if the input is not valid, or error. In this case you may want to try using the ServerName property.
  • IsIntegratedSecurityOnly: Server is in Integrated Security mode. I found this one particularly useful to troubleshoot SQL Server installations for GP, especially when the server has been 'accidentally' configured for Integrated Security instead of Mixed Mode.1 = Integrated security. 0 = Not Integrated security. NULL = Input is not valid, or an error.
  • LicenseType: Mode of this instance of SQL Server.
    PER_SEAT = Per Seat mode
    PER_PROCESSOR = Per-processor mode
    DISABLED = Licensing is disabled.
  • ProductVersion: Version of the instance of SQL Server, in the form of 'major.minor.build'. Can also be obtain with SELECT @@VERSION
  • SQLSortOrderName: The SQL sort order name from the collation.
Here are couple examples of the results I obtained while running SERVERPROPERTY against my SQL Server:

select serverproperty('Collation')
---------------------------------------------------------------------------
SQL_Latin1_General_CP1_CI_AS


select serverproperty('Edition')
---------------------------------------------------------------------------

Standard Edition

select serverproperty('EngineEdition')
---------------------------------------------------------------------------
2


select serverproperty('ServerName')
---------------------------------------------------------------------------

MGB001

select serverproperty('IsIntegratedSecurityOnly')
---------------------------------------------------------------------------

0

select serverproperty('LicenseType')
---------------------------------------------------------------------------

DISABLED

select serverproperty('ProductVersion')
---------------------------------------------------------------------------

9.00.3054.00


select serverproperty('SQLSortOrderName')
---------------------------------------------------------------------------
nocase_iso

I hope you find SERVERPROPERTY a very usefull function and the one stop shop for a bunch of information on SQL Server properties. If you would like the complete list of properties dont visit http://msdn.microsoft.com/en-us/library/ms174396.aspx or open SQL Server Books Online and type in SERVERPROPERTY in the Look For line.

Until next post!

MG.-
Mariano Gomez, MIS, MCP, PMP
Maximum Global Business, LLC
http://www.maximumglobalbusiness.com/

Comments

Popular posts from this blog

Power Apps - Application Monitoring with Azure Application Insights

DBMS: 12 Microsoft Dynamics GP: 0 error when updating to Microsoft Dynamics GP 2013 R2

eConnect Integration Service for Microsoft Dynamics GP 2010