Use EXPANDENVIRONMENTVARS() to expand the environment variable before feeding it into the SQL statement and see also the DBCommand() UDF.
_________________________
There are two types of vessels, submarines and targets.