Contents
Environment & System Variables - Embedding Parameters in SQL Code

System Variable List

The following System Variables are currently supported in Combine (note that the syntax of System Variables is <%VariableName%>):

<%Execution_DatabaseName%> - The name of the target database as it was obtained by running SELECT DB_NAME(). If this variable is included in the SQL code, then Combine executes SELECT DB_NAME() before code is deployed on each target database and then replaces the variable name with the result of this SELECT statement. For example, if code is executed against a database called MyDB, then the value of this System Variable will be replaced with the string MyDB in runtime.

Note: The <%Execution_DatabaseName%> is the name of the target database for the entire script. If a SQL script uses the USE clause to change databases in runtime, then the value of <%Execution_DatabaseName%> is the name of the original target database and not the one used after the USE clause. For example, if the following script is run against the master database

USE msdb
GO

SELECT '<%Execution_DatabaseName%>'
GO

then Combine will replace the variable value with the string master, since master is the target database for the script.


<%Execution_InstanceName%> - The name of the SQL Server instance that holds the target database where code is executed, as it was obtained by running SELECT SERVERPROPERTY('ServerName') and by parsing the string after the forward slash if it exists (e.g., when the server name is MyServer\Instance1 then the instance name is Instance1). If this variable is included in the SQL code, then Combine executes SELECT SERVERPROPERTY('ServerName') before the code is deployed and then replaces the variable name with the parsed instance name. For default (i.e., non-named) SQL Server instances, the value of this variable is an empty string.

<%Execution_ServerName%> - The name of the SQL Server that contains the target database where the code is executed, as it was obtained by running SELECT SERVERPROPERTY('ServerName') and by parsing the string before the slash if it exists (e.g., when the result of the SELECT statement is either MyServer\Instance1 or MyServer, then the server name is MyServer). If this variable is included in the SQL code, then Combine executes SELECT SERVERPROPERTY('ServerName') before the code is deployed and then replaces the variable name with the server name in runtime.

<%Execution_ServerAndInstanceName%> - The name of the SQL Server together with the instance name. For example, if code is executed against a database that belongs to a SQL Server instance called MyServer\Inst1 then the System Variable will be replaced with MyServer\Inst1 in runtime. For default (i.e., non-named) instances, the value of this System Variable is identical to the value of the System Variable <%Execution_ServerName%>.

<%Container_DatabaseName%> - The name of the database where SQL code is executed, as it was defined in the Container Manager. For example, if code is executed against a Container that points to three databases (on any number of servers) named DB1, DB2 and DB3, then the value of the System Variable will be replaced in runtime with the appropriate database name for each database. Note that this value may be different than the value of the corresponding System Variable described above <%Execution_DatabaseName%> since the latter is retrieved in run-time by running SELECT DB_NAME() against each target database whereas the System Variable <%Container_DatabaseName%> is the database name as it was defined in the Container Manager.

<%Container_InstanceName%> - The name of the SQL Server instance that contains a target database as it was defined in the Container Manager. For example, if you deploy code that embeds this System Variable against a Container, and the Container has a database that resides on a named instance and the instance name is defined in the Container Manager, then the value of this System Variable will be replaced with the instance name you defined in the Container Manager. However, if you define a Container that points to a database on a named instance using aliases or by specifying the port of the target instance (e.g., by using Dynamic Containers), then the value of this System Variables will be replaced with an empty string. Note that the difference between this System Variable and <%Execution_InstanceName%> is that the latter is resolved in runtime by querying the target database for the instance name on which it resides, whereas <%Container_InstanceName%> is simply taken from the settings in the Container Manager without resolving the actual instance name.

<%Container_ServerName%> - The name of the server that contains the target database on which code is executed, as it is defined in the Container Manager. The value of this System Variable does not include the instance name. Furthermore, if you define servers in the Container Manager using aliases, then the value of the System Variable will be replaced with the alias name and not the actual server name, as is the case with <%Execution_ServerName%>, since the latter is resolved in runtime by querying the target database whereas the value of <%Container_ServerName%> is taken from the Container Manager settings.

<%Container_ServerAndInstanceName%> - The name of the server and instance that contains a target database, as it was defined in the Container Manager. The value of this variable is synonymous to the value of the combined string <%Container_ServerName%>\<%Container_InstanceName%>.




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