title: How do I use an if statement inside the where clause in this sql statement?
body: <pre><code> select * 
   from mytable
   where (if @key=0 
             pkey&gt;=0
          else
             pkey = @key)
  </code></pre>
  
  <p><code>@key</code> is the value passed in to the stored procedure and <code>pkey</code> is a column in <code>mytable</code>.</p>