title: Alternatives to IF ELSE in stored procedure SQL Server
body: <p>I am new to stored procedures and still learning, below is what I tried and is working also. But, I have only one change on <code>ad.Indicator</code> and I am writing the same query thrice in <code>IF, ELSE IF</code>. </p>
  
  <p>Is there a better way to do this? (I am using SQL Server)</p>
  
  <pre><code>ALTER PROCEDURE TestingSP 
      @startdate Datetime, 
      @enddate Datetime,
      @source Varchar(10)
  AS 
  BEGIN 
     IF(@source = 'None')
        SELECT *
        FROM FD.T fd 
        INNER JOIN AD.T ad ON fd.OCD = ad.ACD 
        WHERE fd.SG BETWEEN @startdate AND @enddate
  
     ELSE IF(@source = 'Air')
        SELECT *
        FROM FD.T fd 
        INNER JOIN AD.T ad ON fd.OCD = ad.ACD 
        WHERE fd.SG BETWEEN @startdate AND @enddate AND ad.Indicator = 'True'
  
    ELSE IF(@source = 'Not Air')
        SELECT *
        FROM FD.T fd 
        INNER JOIN AD.T ad ON fd.OCD = ad.ACD 
        WHERE fd.SG BETWEEN @startdate AND @enddate AND ad.Indicator = 'False'
  END
  </code></pre>