Page 1 of 1

Use of user environment variables

Posted: Tue Jan 26, 2010 5:05 pm
by barry.marcus
I'm wondering if there is a way to utilize environment variables in a tsql script that will be run from both a vortex script using exec, as in:

<$scriptFile="/somepath/myscript.sql">
<exec FROMFILE=$scriptFile BKGND -- tsql -d $masterDb>
</exec>

as well as from the command line, as in:

tsql < /somepath/myscript.sql

and where a line in myscript.sql might look something like:

SELECT * FROM %TABLEVAR%;

Also, if something like this *is* possible, where and how do I set the environment variable TABLEVAR?

Thanks.

Use of user environment variables

Posted: Wed Jan 27, 2010 10:02 am
by John
No, you can't use environment variables in tsql.

The simplest solution is probably a Vortex script to run the SQL instead of tsql, e.g.

<SQL "SELECT * FROM " $TABLEVAR></SQL>

and pass in $TABLEVAR

texis TABLEVAR=TableName Script

or TABLEVAR could be set in the environment.