0
update p
set p.storePrice = 
    CASE 
       WHEN p.costPrice BETWEEN 0.00 AND 1.00 
       THEN p.costPrice * 1.0
    CASE 
       WHEN p.costPrice BETWEEN 0.00 AND 1.00 
       THEN p.costPrice * 1.0
    ELSE 
       p.msrpPrice
    END
FROM product p                      
WHERE p.type = 1

The error says:

Msg 156, Level 15, State 1, Line 9
Incorrect syntax near the keyword 'CASE'.

I can't seem to see any issue with the sql?

2 Answers 2

4

There are two starting case's. Remove the second one, like:

case 
    when x=1 then ...
    when x=2 then ...
end
Sign up to request clarification or add additional context in comments.

Comments

2

Try with:

UPDATE p
    SET 
     p.storePrice = 
            CASE 
                WHEN 
                    p.costPrice BETWEEN 0.00 AND 1.00 
                    THEN p.costPrice * 1.0

                WHEN 
                    p.costPrice BETWEEN 0.00 AND 1.00 
                    THEN p.costPrice * 1.0                              

                ELSE 
                    p.msrpPrice
            END
FROM product p                    
WHERE p.type = 1

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.