title: SQL Server stored procedure WHERE clause
body: <p>Need help with <code>WHERE</code> clause in this stored procedure.</p>
  
  <p>How to write <code>WHERE</code> with this parameters and if any of these param contains specific value, then I need to get all values from that column ?</p>
  
  <p>Sample if <code>@post1</code> contains 1 then select values from that columns that are equals to 1.
  But if <code>@post1</code> contains 0 than select all values from that column. And that for all other parameters. </p>
  
  <pre><code>ALTER PROCEDURE [dbo].[spStavke] 
      @dat1 date,
      @dat2 date,
      @god int, 
      @post1 int,
      @post2 int,
      @post3 int
  AS
  BEGIN
      SET NOCOUNT ON;
  
      SELECT 
         [test1]
        ,[test2]
        ,[test3]
        ,[test3]
      FROM 
        [PN].[dbo].[Stavke] AS stavke
      LEFT JOIN 
        PN.dbo.Tip AS tip ON stavke.Vrsta = tip.id
      LEFT JOIN
        PN.dbo.Vrsta AS vrs ON stavke.Jedinica = vrs.id
  END
  </code></pre>