Database Engine version Numbers (select @@version) RRS feed

  • Question




    I use the "select @@version" statement to recognize, if the SQL-Server Version is 2000, 2005 or 2008, additional I parse the Build, too.



    SQL 2008 returns "Microsoft SQL Server 2008 (RTM) - 10.0.1600.22 (Intel X86) Jul  9 2008 14:43:34  ..."
    SQL 2005: returns "Microsoft SQL Server 2005 - 9.00.3073.00 (Intel X86) Aug  5 2008 12:31:12 ..."
    SQL 2000: returns "Microsoft SQL Server  2000 - 8.00.2050 (Intel X86) Mar  7 2008 21:29:56 ..."


    You see, SQL2008 has the information "(RTM)" - if I parse the String, I have to cut RTM off. (I parse using Instr("(")-3 to get the Build number. Sure I could choose another search criterion, but it woud only move the problem)


    I need an Overview of possible returns of "select @@version" for SQL2008 because I think, there could be other text than RTM. Is the an official overview? If not, it would help me, you post your Result (only needed for 2008)


    Thank you!

    Friday, October 31, 2008 9:55 AM

All replies


    In order to get SQL Server version, you can check its version number instead of string "microsoft sql server "

    Example: 8 is SQL 2000, 9 is 2005 and 10 is 2008


    If you just want to know if its 2000. 2005 or 2008, you can parse string for "-" and get next version number.


    I hope this helps you.

    Tuesday, November 4, 2008 9:51 AM