Script Variables


Script Variables provide you with the flexibility of using a single script in multiple scenarios. For example if you need to run single script against multiple databases, instead of modifying the script for each database, you can use a scripting variable for the database name. Your define Script Variable by using following syntax:

DEFINE var_name [=] var_value

where var_name is Script Variable name and var_value it's value. DEFINE statement should be the first statement on a line. Also it should be the first statement in a batch Everything after variable name or '=' considered to be variable value.

 

Example of using Script Variables:

DEFINE var_date = 01/01/07
DEFINE var_string 'String_Value'
SELECT * FROM table_name where date_field = '$(var_date)' and string_field = $(var_string) 

Script Variables naming rules