Contents Index CREATE TRIGGER statement [T-SQL] CREATE VIEW statement

ASA SQL Reference
  SQL Statements

CREATE VARIABLE statement


Description 

Use this statement to create a SQL variable.

Syntax 

CREATE VARIABLE identifier data-type

Usage 

The CREATE VARIABLE statement creates a new variable of the specified data type. The variable contains the NULL value until it is assigned a different value by the SET statement.

A variable can be used in a SQL expression anywhere a column name is allowed. If a column name exists with the same name as the variable, the variable value is used.

Variables belong to the current connection, and disappear when you disconnect from the database or when you use the DROP VARIABLE statement. Variables are not visible to other connections. Variables are not affected by COMMIT or ROLLBACK statements.

Variables are useful for creating large text or binary objects for INSERT or UPDATE statements from embedded SQL programs.

Local variables in procedures and triggers are declared within a compound statement (see Using compound statements).

Permissions 

None.

Side effects 

None.

See also 

BEGIN statement

SQL Data Types

DROP VARIABLE statement

SET statement

Standards and compatibility 
Example 

For an example, see SET statement


Contents Index CREATE TRIGGER statement [T-SQL] CREATE VIEW statement