<p>I have a report in SSRS 2005 that's based on a query that's similar to this one: </p>

<pre><code>SELECT * FROM MyTable (NOLOCK) 
WHERE col1 = 'ABC'
AND col2 LIKE '%XYZ%'
</code></pre>

<p>I need to be able to dynamically include the AND part of the WHERE clause in the query based on whether the user has checked a checkbox. Basically, this is a dynamic SQL statement and that's the problem. I tried several approaches to no avail. Is this possible? Does SSRS 2005 supports dynamic SQL? Thanks!</p>

Perhaps this would work for you:
```
```
if @checked = 1
    select * from mytable (nolock) where col = 'ABC'
else
    select * from mytable (nolock) where col = 'ABC' AND colw Like '%XYZ%'
```
```
I'm sorry I don't use SSRS much, but if you can get the value of the checkbox into the @checked parameter this should work.
Alternately you could use a CASE WHEN statement.