I have a problem with SQL, I have not yet found a solution, what I'm trying to do is where clause for a procedure in which the userID variable can contain either a valid user ID or -1 to indicate all users.
However, I am stuck in this part of the where clause:
AND usertable.userid = CASE WHEN @user = -1
THEN
ELSE
@user
END
I am not sure how to handle -1 to indicate all users
thank
source
share