title: How to check multiple conditions by passing parameters to a SQL Server stored procedure
body: <p>I am facing a problem in procedure the situation is.</p>
  
  <p>I have to check multiple conditions using if else in the procedures, which is taking more time to execute. </p>
  
  <p>The procedure structure as follows</p>
  
  <pre><code>create procedure sp_CheckMultipleconditions
      @Con1 varchar(10) = null,
      @con2 int = null,
      @con3 int = null,
      ..
      @Con6 varchar(10) = null
  as
  BEGIN
     if(@con1 is not null)
     begin
        ----- statement ----
     end
  
     else if(@Con2 is not null)
     begin
        ----- statement ----
     end
     .
     .
     .
     else if(@Con2 is not null and @Con3 is not null)
     begin
       .
       .
       .
     end
  END
  </code></pre>
  
  <p>In this way I wrote the procedure it is having 36 if else conditions which is taking more time, can anyone please suggest a better way?</p>
  
  <p>Thanks</p>