Reputation: 1
WHERE
CASE
WHEN @TypeFatt <> -1
THEN docAM.typCIGA = @TypeFatt
ELSE docAM.typCIGA > @TypeFatt
END
The error is
Incorrect syntax near '='
Why?
Thanks for your help
Upvotes: 0
Views: 27
Reputation: 44795
It's generally better to use regular AND
/OR
constructions instead of case
expressions in the WHERE
clause:
WHERE (@TypeFatt <> -1 AND docAM.typCIGA = @TypeFatt)
OR (@TypeFatt = -1 AND docAM.typCIGA > @TypeFatt)
Upvotes: 1