SQL Server – How to Get Major and Minor Version

sql serversql-server-2008

Running following query:

SELECT 
    SERVERPROPERTY('productversion') AS version,
    SERVERPROPERTY('ProductMajorVersion') AS major, 
    SERVERPROPERTY('ProductMinorVersion') AS minor;

produces the following results:

version      major   minor
------------ ------- -------
10.0.2531.0  NULL    NULL

What am I missing?

Best Answer

The ProductMajorVersion and ProductMinorVersion properties are only available in SQL Server 2012 and above (according to https://docs.microsoft.com/en-us/sql/t-sql/functions/serverproperty-transact-sql). Your product version indicates that this is SQL Server 2008 SP1, which does not support the two other properties.