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--