title: How to use Switch in SQL Server
body: <p>I want to use <code>CASE</code> in my stored procedure. I am getting some syntax error in my code:</p>
  
  <pre><code>select 
     case @Temp
     when 1 then (@selectoneCount=@selectoneCount+1)
     when 2 then (@selectoneCount=@selectoneCount+1)
     end
  </code></pre>
  
  <p>When running, I'm getting:</p>
  
  <blockquote>
    <p>incorrect syntax near '='.</p>
  </blockquote>
  
  <p>at this line here:</p>
  
  <pre><code>@selectoneCount = @selectoneCount + 1
  </code></pre>
  
  <p>near the equal. </p>
  
  <p>Actually I am getting return value from a another sp into @temp and then if @temp =1 then I want to increment the count of @SelectoneCount by 1 and so on.
  Please let me know what is the correct syntax. </p>