Environment & System Variables - Embedding Parameters in SQL Code

Creating New Environment Variables

Environment Variables can be created in the Edit Environment Variables dialog. To do so, choose one of the following options as illustrated in the image below. After variables are created, they can be referenced in SQL code using the format <$VariableName$>, as demonstrated later in this section.
1. In the Container Manager, select your environment and choose Edit Environment Variables in the right-click menu.
2. Select your environment in the Container Manager and press F4 to view the Properties window. Then, in the Properties window, expand the Variables node and click the Browse button.

Figure 102.1:  Starting the Edit Environment Variables dialog.

In order to create a new Environment Variable, under Add/Update Variable, first enter the name of the new variable. Then, enter the variable value and click the Add button, as demonstrated in Fig. 102.2.

Figure 102.2:  Creating a new Environment Variable.

After you press the Add button, the new variable will appear in the list of variables with a pencil icon next to it, as in Fig. 102.3. Once you are done adding variables, press OK to complete the dialog. The new variables will then be available in the Properties window for the environment you selected earlier.

Figure 102.3:  Viewing the Environment Variables after a new variable is created.

After the variables are created, they can now be referenced in the code. To use them, the format <$VariableName$> must be used. For example, Fig. 102.4 shows SQL code that uses the LinkedServerName and TableOwner environment variables.

Figure 102.4:  Using Environment Variables in SQL Code.

Another way to create Environment Variables is by copying variables that were previously defined for other environments. Please refer to the section Copying Environment Variables from Another Environment for additional information.

© 2001-2018 JNetDirect, Inc. All Rights Reserved.