I have a problem with SQL that I have not yet found a solution to, what im trying to do is a where clause for a procedure where a userID variable can contain either a valid userID or -1 to indicate all users.
However im stuck at this part of the where clause:
AND usertable.userid = CASE WHEN @user = -1
THEN
ELSE
@user
END
I’m not sure how to process the -1 to say select all users
Thanks
Perhaps the following would work:
Share and enjoy.