title: SQL - Adding/Disabling a Where clause based on a boolean condition in Select Statement (ASP.net SQLDataSource)
body: <p>I have a SQL select statement that is basically just</p>
  
  <pre><code>SELECT * FROM myTable 
  WHERE status != 5
  </code></pre>
  
  <p>It is a lot more complex than in reality, but its mostly convoluted column names and joins.</p>
  
  <p>what i want to be able to do is on a parameter being a value, I disable the where clause, i.e.</p>
  
  <pre><code>SELECT * FROM myTable 
  where CASE WHEN @parameter = 'true'
  THEN --...add the where clause ('status != 5')
  </code></pre>
  
  <p>It doesn't work like that but does anyone have a different method of approach? i'm using ASP.net with the select in an SQLDatasource if that opens up any options. It's to do with hiding particular records from non-logged in users but showing others.</p>
  
  <p><b>TL;DR:</b> Can I enable/disable a where clause based on a parameter in SQL or ASP.net</p>