December 29, 2005 at 11:49 pm
begin
select ls_action = 0
end
December 30, 2005 at 1:43 am
It is just as valid as
BEGIN
SELECT 0 AS ls_action
END
It is just a different way of writing it.
December 30, 2005 at 7:37 am
It's the same as:
BEGIN
SET ls_action = 0
END
-SQLBill
December 30, 2005 at 8:24 am
As David pointed out,
begin
select ls_action = 0
end
and
BEGIN
SELECT 0 AS ls_action
END
are equivalent. The first form is from very early versions of sql server and dates back to the sybase days.
Please note that the first form would be the equivalent of a SET statement if ls_action were a variable such as @ls_action.
As is the first statement is only giving the column name ls_action to the selected value of 0.
ron
December 30, 2005 at 8:46 am
From BOL:
< select_list > ::=
{ *
| { table_name | view_name | table_alias }.*
| { column_name | expression | IDENTITYCOL | ROWGUIDCOL }
[ [ AS ] column_alias ]
| column_alias = expression
} [ ,...n ]
December 30, 2005 at 12:37 pm
Nope... it's not... SET ls_action=0 will fail in the absence of other code. You either have to declare ls_action as variable (don't forget to add the @ sign) or you have you have to turn the code into an UPDATE. But, by itself, SET ls_action=0 will give you an "Incorrect Syntax near "="" message.
Now, as others have pointed out, SELECT ls_action=0 will work by itself. It will return a zero in a column named "ls_action" and the equivelent code is SELECT 0 AS ls_action.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply