title: Add WHERE clauses to SQL dynamically / programmatically
body: <p>How can I add search condition to SQL Stored Procedure programmatically?
  In my application(C#) I'm using stored procedure (SQL Server 2008R2)</p>
  
  <pre><code>ALTER PROCEDURE [dbo].[PROC001]
  @userID varchar(20),
  @password varchar(20)
  AS
  SELECT * FROM tUsers WHERE RTRIM(Name) = @userID AND RTRIM(Password) = @password
  </code></pre>
  
  <p>I want to extend this query by more conditions, and now I don't know how many conditions will use this query due program execution.. 2, 3, 6 OR 20. I want to add these conditions programmatically like:</p>
  
  <pre><code>SELECT * FROM tUsers WHERE RTRIM(Name) = @userID AND RTRIM(Password) = @password
  AND Field2 = '1' AND Field3 = '0' OR Field4 &lt;&gt; '8' AND Field5 &lt; '100' ....
  </code></pre>
  
  <p>Is it possible to sent conditions to stored procedure dynamically?</p>