title: case in sql stored procedure on SQL Server
body: <p>Based on a parameter I'd like to execute a different Update in my stored procedure.  I've tried many permutations of the code below, but I always have errors.</p>
  
  <pre><code>    @EmpID int = 0, 
  @NewStatus nvarchar(10) = 0
  AS
  BEGIN
  SET NOCOUNT ON;
  
  select CASE   @NewStatus 
  
  when    'InOffice' then 
       Update tblEmployee set InOffice = -1 where EmpID = @EmpID
  when   'OutOffice' then 
      Update tblEmployee set InOffice = -1 where EmpID = @EmpID
  when 'Home' then 
      Update tblEmployee set Home = -1 where EmpID = @EmpID
  
  END
  </code></pre>