Thank you very much Dmitry!

With some slight modification to the query I was able to get the data i needed.



Thanks for your replies

I guess just beeing able to loop through all namespaces would be good enough.
When looking a bit closer at the ODBC interface it seems possible to change namespace for a DSN by setting a registry key.
Basically doing as a quick hack:

set HKLM:\SOFTWARE\ODBC\ODBC.INI\instance\Namespace to %SYS
query all namespaces with "select Name from Config.Namespaces where CPFName='CACHE' and Id like 'CACHE||Namespaces||%' and Name not in ('%ALL','%SYS')"
loop that result

set HKLM:\SOFTWARE\ODBC\ODBC.INI\instance\Namespace to "namespace name"
query Ens.MessageHeader

repeat loop

A bit ugly but it worked.

However, for namespaces with lots of messages (5+ million) my query on Ens.MessageHeader times out.
Are there limits on how SQL queries through ODBC can perform, or is it more up to how the query is written?

I'm thinking now if it's perhaps better to switch approach, and create a native routine to loop the namespaces.

What would be a good way to access message metadata from a routine?