Groups | Blog | Home
all groups > sql server programming > october 2006 >

sql server programming : declaring variables


--CELKO--
10/28/2006 6:03:25 PM
Proprietary syntax; the Standard SQL/PSM does not have the AS option so
avoid it to make you code more readable and portable. Also give the
arguement a meaningful name that is unique when the @ is removed. This
@ is an aid to a one-pass compiler.
Arnie Rowland
10/28/2006 6:30:13 PM
The word 'AS' is optional; not part of the SQL standard, but used by T-SQL.

You will find that most senior dbas and developers do not use the word 'AS'.
We often work with different database products, and since it is not part of
the standard, we don't bother.

--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc

Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous

You can't help someone get up a hill without getting a little closer to the
top yourself.
- H. Norman Schwarzkopf


[quoted text, click to view]

Keith G Hicks
10/28/2006 8:26:45 PM
In a trigger, function or procedure, what's the difference between this (one
has "AS" and the other doesn't):

DECLARE @MyVar AS INT

and this:

DECLARE @MyVar INT

Other than just technique? They both seem to work fine. I have tons of code
with the "AS" and lots without. I can't find any documentation on this.

Using SQL 2k

Thanks,

Keith

AddThis Social Bookmark Button