title: SQL HELP - Conditional where clause based on a BIT variable - SQL Server
body: <p>I need help writing a conditional where clause. here is my situation:</p>
  
  <p>I have a bit value that determines what rows to return in a select statement. If the value is true, I need to return rows where the import_id column is not null, if false, then I want the rows where the import_id column is null.</p>
  
  <p>My attempt at such a query (below) does not seem to work, what is the best way to accomplish this?</p>
  
  <pre>
  <code>
  DECLARE @imported BIT
  
  SELECT id, import_id, name FROM Foo WHERE
      (@imported = 1 AND import_id IS NOT NULL)
      AND (@imported = 0 AND import_is IS NULL)
  </code>
  </pre>
  
  <p>Thanks.</p>