Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Case
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Re: Case
Miscellaneous
Thread ID:
00822321
Message ID:
00822341
Views:
10
The CASE is a function that returns values depending on conditions. It cannot be used for conditional excution of T-SQL statements. You should use IF statement to control program flow.

>Hi All:
> When I compile the following lines of code in sql query analyzer I get an error message. The error is:
>SELECT EXPR1,
>       Case RTRIM(DESCRIPTION_A)
>       When  'LOC_PRICE' then
>         Update Prcy_Export_Club_Details set Loc_Price = Expr1
>       When 'TXI_AMT1' then
>         Update Prcy_Export_Club_Details set TXI_AMT1 = Expr1
>       End
>WHERE BILL_ID = PRCY_EXPORT_CLUB_DETAILS.BILL_ID
>error:
>Server: Msg 156, Level 15, State 1, Line 4
>Incorrect syntax near the keyword 'Update'.
>Server: Msg 156, Level 15, State 1, Line 5
>Incorrect syntax near the keyword 'When'.
>Server: Msg 156, Level 15, State 1, Line 7
>Incorrect syntax near the keyword 'End'.
>
>Can anyone tell me what am I doing wrong?
>Thanks
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform