Interview Question of the Week #028 – T-SQL Script to Detect SQL Server Version and Property

Here is a very basic question I just came across the other day. I was interviewing nearly 20 candidates and I found that only 5 of them could write the query (with the help of the internet).

Question: How to determine the version and properties of SQL Server with the help of T-SQL?

Answer: Here is the simple script which can list version of SQL Server:

SELECT SERVERPROPERTY('productversion') ProductVersion,
SERVERPROPERTY ('productlevel') ProductLevel,
SERVERPROPERTY ('edition') Edition

Reference: Pinal Dave (

Previous Post
POSTGRESQL – How to Create Function? – How to Declare Local Variable
Next Post
SQL SERVER – How to Change Server Name?

Related Posts

No results found.

8 Comments. Leave new

  • Dear Sir
    SELECT @@Version gives similar results .. whats the difference between these two ?

    • The difference is that you need to parse the result of @@version to get details in specific

  • Everton Custodio
    July 12, 2015 8:18 am

    Is the instruction @@VERSION a valid answer? Like in SELECT @@VERSION.

    • Everton – As madhivanan said, you need to parse results if you want to use in subsequent queries.

  • As an interviewer I find questions like these not as useful as finding out if the candidate can use available tools to answer the question. Tools including Google. What is the point of hiring someone that can wow you in an interview then in real life can’t solve simple real world problems.

  • Robb Keller
    July 15, 2015 2:35 am

    What’s wrong with Select @@Version?

    • Robb – Nothing wrong with @@version. If you want to use the exact build into your script to take any action then you need to parse the output of @@version and find required info like edition etc.

  • Mubashar Anwer
    August 3, 2015 7:00 pm

    i enjoying learning Through Your usefull Blogs . Sir You Doing A great Job


Leave a ReplyCancel reply

Exit mobile version