title: Stored procedure big where clause or multiple procedures
body: <p>Is it better to have one big query or N small ones which will be called via code?</p>
  
  <p>For example to select all the customers with multiple parameters:</p>
  
  <pre><code>select
     id,
     name,
     firstname,
     city,
     birthday,
     ...
  from dbo.Customers
  where (@Name is null or name like @Name)
  and (@FirstName is null or firstname like @FirstName )
  and (@City is null or city @City)
  and (@Birthday is null or birthday = @Birthday)
  </code></pre>
  
  <p>Or too have multiple stored procedures like</p>
  
  <pre><code>select
     id,
     name,
     firstname,
     city,
     birthday,
     ...
  from dbo.Customers
  where (@Name is null or name like @Name)
  and (@FirstName is null or firstname like @FirstName)
  </code></pre>
  
  <hr>
  
  <pre><code>select
     id,
     name,
     firstname,
     city,
     birthday,
     ...
  from dbo.Customers
  where city like @City
  </code></pre>
  
  <hr>
  
  <pre><code>select
     id,
     name,
     firstname,
     city,
     birthday,
     ...
  from dbo.Customers
  where  birthday = @Birthday
  </code></pre>