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

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

Reference: Pinal Dave (https://blog.sqlauthority.com)

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 ?

    Reply
  • Everton Custodio
    July 12, 2015 8:18 am

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

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

      Reply
  • 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.

    Reply
  • What’s wrong with Select @@Version?

    Reply
    • 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.

      Reply
  • Mubashar Anwer
    August 3, 2015 7:00 pm

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

    Reply

Leave a Reply