title: Querying different table based on a parameter
body: <p>I have a stored procedure that I would like to query either the production or the "work in progress" table, based on the parameter I am passing in. I could write two separate stored procedures, but I thought this was worth a try.</p>
  
  <p>something along the lines of:</p>
  
  <pre><code>create procedure getUserDetails
      @userID int,
      @prod varchar(5)
  as 
      begin
          select * from
              if (@prod = 'true')
              Begin
                  userprod_table
              else
                  userwip_table
              end 
      where something = 'something'
  END
  </code></pre>
  
  <p>Is this at all possible? I wouldn't want to write 2 SP that are almost identical :-/</p>