Local variables  Local variables and select statements

Chapter 14: Using Batches and Control-of-Flow Language

Declaring local variables

To declare a local variable’s name and datatype use:

declare @variable_name datatype 
   [, @variable_name datatype]...

The variable name must be preceded by the @ sign and conform to the rules for identifiers. Specify either a user-defined datatype or a system-supplied datatype other than text, image, or sysname.

It is more efficient in terms of memory and performance to write:

declare @a int, @b char(20), @c float

than to write:

declare @a int
declare @b char(20)
declare @c float




Copyright © 2005. Sybase Inc. All rights reserved. Local variables and select statements

View this book as PDF