ODBC Server Reference Manual

Transact-SQL Language
HP NonStop ODBC Server Reference Manual429151-002
4-62
Examples
Examples
The following statements declare variables and assign them values.
declare @veryhigh money
select @veryhigh = max(price) from titles
NonStop ODBC Server Compared With SQL Server
When used through the NonStop ODBC Server, DECLARE differs from the SQL
Server implementation in the following way:
Referencing Null Variables
When you declare a variable, its value is NULL. You must assign a value with a
SELECT statement before referencing the variable.
For example, the following statements declare the variables @v1 and @v2, then
assign the value of variable @v1 (which is null) to the variable @v2, causing an error:
declare @v1 int, @v2 int
select @v2 = @v1
If, however, you assign a value to @v1, you can assign its value to @v2. The following
statements do not cause an error:
declare @v1 int, @v2 int
select @v1 = 55
select @v2 = @v1
Variables are described under Language Elements
on page 4-5.
NonStop ODBC Server Compared With NonStop SQL/MP
NonStop SQL/MP does not have a statement that corresponds to DECLARE.
Feature In SQL Server
In Programs Used With the NonStop
ODBC Server
Can you reference a
variable when its value is
null?
Yes No