Discussion:
incorrect syntax near keyword SET
(too old to reply)
Jeff
2008-09-16 23:58:43 UTC
Permalink
Hey

I get the incorrect syntax near keyword SET :(

This SP is created using Sql Server 2005 Enterprise, At my comp I don't have
that version of Sql Server. I use instead that FREE express vesion of Sql
Server 2005. The deal is that my boss created this SP on his machine and
then sent it to me... So I was wondering if for example there is a
difference in what is allowed to do in SP between Sql server 2005 enterprise
and the FREE express version. I mean the SP only have SELECTS, IF, CASE,
WHEN... I thought atleast that was allowed on the free vesion as well...


Here part of the SP, just in case you see something wrong with it... (the
last line I get that incorrect keyword at....)

@returparam nvarchar(25) OUT
DECLARE @str as nvarchar(25);

ELSE IF @filter IS NULL
SELECT CASE @tbl
WHEN N'normal' THEN (SELECT id, name, desc FROM Customer)
ELSE SET @returparam = @str;

Best Regards...
Dan Guzman
2008-09-17 00:21:07 UTC
Permalink
Post by Jeff
I get the incorrect syntax near keyword SET :(
snip <
WHEN N'normal' THEN (SELECT id, name, desc FROM Customer)
I don't see how this could work in any version of or edition of SQL Server.
CASE is an expression rather than a control-of-flow statement. You need an
IF statement to do different things conditionally:

IF @tbl = N'normal'
SELECT id, name, desc FROM Customer
ELSE
SET @returparam = @str;
--
Hope this helps.

Dan Guzman
SQL Server MVP
http://weblogs.sqlteam.com/dang/
Post by Jeff
Hey
I get the incorrect syntax near keyword SET :(
This SP is created using Sql Server 2005 Enterprise, At my comp I don't
have that version of Sql Server. I use instead that FREE express vesion of
Sql Server 2005. The deal is that my boss created this SP on his machine
and then sent it to me... So I was wondering if for example there is a
difference in what is allowed to do in SP between Sql server 2005
enterprise and the FREE express version. I mean the SP only have SELECTS,
IF, CASE, WHEN... I thought atleast that was allowed on the free vesion as
well...
Here part of the SP, just in case you see something wrong with it... (the
last line I get that incorrect keyword at....)
@returparam nvarchar(25) OUT
WHEN N'normal' THEN (SELECT id, name, desc FROM Customer)
Best Regards...
--CELKO--
2008-09-17 04:57:38 UTC
Permalink
WHEN N 'normal'
THEN (SELECT id, name, desc FROM Customer) --WTF????
ELSE SET @returparam = @str --WTF????
END:

CASE is an expression -- NOT A STATEMENT!!!! It returns a value and
not an action, like assignment and all that crap you had.

Your whole approach to SQL coding is wrong. Please stop and read a
book before you post again.

Loading...