SQL version

  • 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)

  • 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]

  • --pull first four digits in a row that start with 2, should be year.

    SELECT SUBSTRING(@@VERSION, PATINDEX('%2[0-9][0-9][0-9]%', @@VERSION), 4)

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • You can also pull all kinds of useful information from SERVERPROPERTY.

    SELECT

    SERVERPROPERTY('ProductVersion') AS ProductVersion,

    SERVERPROPERTY('Edition') AS Edition

    If you don't know the product name from the major builds versions you can always check them out here.


    SELECT quote FROM brain WHERE original = 1
    0 rows returned

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply