title: SQL Server Conditions in Where Clause
body: <p>I am taking an SQL Server class. I am having trouble with a Conditional Where clause in a stored procedure. 2 of the 3 parameters could be Null.</p>
  
  <pre><code>@Service nvarchar(50),
  @Country nvarchar(50)  = NULL,
  @Region nvarchar(50) = NULL
  
  as 
  
  SELECT
    CASE @Service
      WHEN 'Army' THEN Sum(Army)
      WHEN 'Navy' THEN Sum(Navy)
      When 'Marine_Corps' then Sum(Marine_Corps)
      When 'Air_Force' then Sum(Air_Force)
                  ELSE NULL
    END
  
    as "ServiceTotal"
  
  FROM
    All_Records
  
   WHERE 
  
  if @Country is not null @Country and if @Region !=Null @Region = Region
  </code></pre>
  
  <p>How can I restructure the Where clause? I am coming from an Access background.</p>
  
  <pre><code>GetTotals Navy
  
  OR
  
  GetTotals Navy,Albania,Europe
  </code></pre>
  
  <p>I would like to make the Service mandatory and Country and Region optional. So I want to be able to call the procedure like. So, if I don't specify Region and Country, it should just return all Navy.</p>
  
  <p>Is this possible?</p>