Use of user environment variables

Post Reply
barry.marcus
Posts: 288
Joined: Thu Nov 16, 2006 1:05 pm

Use of user environment variables

Post 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.
User avatar
John
Site Admin
Posts: 2597
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH
Contact:

Use of user environment variables

Post 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.
John Turnbull
Thunderstone Software
Post Reply