title: SQL where clause with case statement
body: <p>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.</p>
  
  <p>However im stuck at this part of the where clause:</p>
  
  <pre><code>AND usertable.userid = CASE WHEN @user = -1
  THEN
  
  ELSE
    @user
  END
  </code></pre>
  
  <p>I'm not sure how to process the -1 to say select all users</p>
  
  <p>Thanks</p>