Hi tuyenhx,
First of all, ignore all the replies above. They're all terribly wrong, and the authors of these posts should be very ashamed they posted these "answers". For example, the "ELSE" part is not mandatory in a CASE, there is no "switch" command, suggesting IF/ELSE with different query's in between is just a very bad solution for multiple reasons, and using ORs like that is convoluted, and again bad programming.
That said, let's get back to the basics: the CASE statement ultimately returns a value. You attempted not to return a value, but to compare or assign something, which doesn't work, as you've noted. I can think of two solutions. In your specific case, having these four conditions, and comparing the project Id to the same value, this should do it, no CASE needed:
WHERE {Project}.[Id] = @Condition
As you'll notice, the "@Condition" value is equal to the number you're comparing "{Project}.[Id]" with, so that works. If there's not always such a 1:1 correspondence, use the following CASE:
WHERE {Project}.[Id] =
CASE @Condition
WHEN 1 THEN 1
WHEN 2 THEN 2
WHEN 3 THEN 3
WHEN 4 THEN 4
END
Notice I've used the alternative CASE syntax by specifying the variable directly after the CASE. This is fully equivalent, but shorter code, to this:
WHERE {Project}.[Id] =
CASE
WHEN @Condition = 1 THEN 1
WHEN @Condition = 2 THEN 2
WHEN @Condition = 3 THEN 3
WHEN @Condition = 4 THEN 4
END
A final word: you really should never compare Ids with literal values like that. Ids should not be trusted to have a specific value, as they are typically autonumbers.