title: Giving conditions in SQL SELECT statement
body: <p>I have to run an SQL query based  on conditions.
  There are 2  AND conditions that needs to be executed only if the if conditions for them are satisfied. Can we use CASE statement here. If so how? Or are there any other methods??</p>
  
  <pre><code>SELECT * FROM MyTable
  WHERE col1=@val1
  
  if condition1 here
  AND col2 = @val2
  end if
  
  if condition2 here
  AND col3 = @val3
  end if
  </code></pre>
  
  <p>Can anyone help me on this please. I am  using sql server 2005.</p>