-1

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.

  • Have you tried `SELECT substring(DATA_AREA_VALUE, 1, 8) FROM qsys2.data_area_info WHERE data_area_library = 'QUSRSYS' and data_area_name = 'QSS1MRI' ` – mao Sep 15 '22 at 14:10
  • I get: "SQL0462 - Procedure or user-defined function OBJECT_STATISTICS in QSYS2 returned a warning SQLSTATE." – Logan Price Sep 15 '22 at 16:25

1 Answers1

1

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'
Mark Barinstein
  • 11,456
  • 2
  • 8
  • 16
  • When I tried your alternate version (AND LOAD_TYPE) It did return values, but it was the IBM i version. The DB2 version is different I believe (but I really do not fully understand the difference). Still, yours is the only answer that yielded a query that actually returned a value. – Logan Price Sep 15 '22 at 16:26
  • [IBM i database frequently asked questions](https://www.ibm.com/docs/en/i/7.5?topic=troubleshooting-i-database-faq): *What level of Db2 for i do I have?* If you are using a IBM i product, you have Db2 for i. The level of Db2 for i is based on the IBM i operating system and is independent of the DB2 versioning scheme. **Because Db2 for i is included with the IBM i operating system, the version, release, and modification level of Db2 for i is the same as that of your operating system.** – Mark Barinstein Sep 15 '22 at 16:52