title: How to have conditional where clause based on parameter value
body: <p>I have following SQL,</p>
  
  <pre><code>DECLARE @EmployeeID Int
  
  SELECT *
    FROM [Northwind].[dbo].[Orders]
    WHERE OrderID = 10248
    AND EmployeeID = @EmployeeID
  </code></pre>
  
  <p>I want to make sure <code>IF @EmployeeID IS NULL</code> Then do not include <code>AND</code></p>
  
  <p>Something like,</p>
  
  <pre><code>SELECT *
    FROM [Northwind].[dbo].[Orders]
    WHERE OrderID = 10248
    IF @EmployeeID IS NOT  NULL
    AND EmployeeID = @EmployeeID
  </code></pre>
  
  <p>I could think of creating a table variable and then filtering them based on parameter value , but is there a better way?</p>