• sqlnewbie17 (5/2/2016)


    How to get only version number from

    select @@version

    Result should be 2000/2005/2008/2012... only

    and not the entire string as here:

    Microsoft SQL Server 2008 R2 (SP3) - 10.50.6000.34 (X64)

    Aug 19 2014 12:21:34

    Copyright (c) Microsoft Corporation

    Standard Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1) (Hypervisor)

    Quick suggestion

    😎

    SELECT SUBSTRING(@@VERSION,22,4) AS [only version number]