InterSystems Cache SQL. Check if table exists

1.8k Views Asked by At

What SQL query can I use to check if a table exists.

I need to support different versions of schema, and some deployments can miss certain tables

1

There are 1 best solutions below

0
On BEST ANSWER

If they are Cache tables, you may use the %Dictionary.CompiledClass system table.

select id from %Dictionary.CompiledClass where SqlSchemaName='%BI' and SqlTableName='Alerts'

Or, if you know Cache class name of your table,

select id from %Dictionary.CompiledClass where ID='%BI.Alerts'

These queries will return 1 row if table %BI.Alerts exists.