Logan Price
Logan Price

Reputation: 121

SQL Query to Get DB2 Version on IBM i

I would like to find out which version of DB2 we are running on our IBM i server using only SQL SELECT.

I am executing my queries via installed ODBC drivers for i Access. The places I am executing the queries are Excel-ODBC and Excel-Microsoft Query (simply because I am not a developer and therefore don't have/don't know of another place to run queries).

The following solutions do not work for me:

How to check db2 version

Get DB2 instance name using SQL

Basic reasons why I have failed to get the above solutions to work:

  1. I do not have a SYSPROC table/have access to SYSPROC table
  2. SYSIBMADM table does not contain a ENV_INST_INFO table.
  3. I think these answers may be tailored to those using IBM z, but I use IBM i.

My end goal is to be able to execute a SQL SELECT and get the version of DB2 used on our server.

Upvotes: 0

Views: 2553

Answers (3)

Tantalus
Tantalus

Reputation: 1

Thank you.

Both of these statements provided the desired results on my server

SELECT RELEASE_LEVEL, TEXT_DESCRIPTION
FROM QSYS2.SOFTWARE_PRODUCT_INFO
WHERE PRODUCT_ID = '5770SS1' 
AND LOAD_TYPE = 'CODE' AND PRODUCT_OPTION = '*BASE'

Release level: V7R5M0   Text description: IBM i

SELECT os_name, os_version, os_release
 FROM SYSIBMADM.ENV_SYS_INFO;

OS_NAME:IBM i   OS_VERSION: 7   OS_RELEASE: 5

Edited to add further details after reading about good answers in the help center:
My response provided two viable alternatives. 
I was directed to these alternatives by stackoverflow responses.
Hopefully my response was legible.  If it was not please comment and I will try to make it clearer.
I appreciate that stackoverflow exists, is user friendly, is supported by professional staff and professional contributors.
Although I looked for an answer to my question elsewhere, I should have gone to stack overflow first!

Upvotes: 0

Charles
Charles

Reputation: 23813

Another option

SELECT os_name, os_version, os_release
 FROM SYSIBMADM.ENV_SYS_INFO;

Should work on 7.2+ which was released in 2014.

Upvotes: 1

Mark Barinstein
Mark Barinstein

Reputation: 12339

Try this:

SELECT RELEASE_LEVEL, TEXT_DESCRIPTION
FROM QSYS2.SOFTWARE_PRODUCT_INFO
WHERE PRODUCT_ID = '5770SS1' 
AND PRODUCT_OPTION = '27'
--or this instead of the above line:
--AND LOAD_TYPE = 'CODE' AND PRODUCT_OPTION = '*BASE'

Upvotes: 1

Related Questions