title: Optional where clause depending on parameter value
body: <p>I want the where statement for this query to be optional depending on what the value of parameter @RetrieveAll is. If @RetrieveAll is false/null the where statement is used, if it is true it should be ignored.</p>
  
  <pre><code>    @IncludeErrors bit = 1,
      @IncludeAccess bit = 1,
      @IncludeLogins bit = 1,
      @RetrieveAll bit = NULL
  SELECT
   //...
  FROM
  (
  
  ) AS a
  WHERE
  a.RowNumber BETWEEN @ItemCountStart AND @ItemCountEnd
  </code></pre>
  
  <p>Is there way to do this?</p>