title: Optional parameters in stored procedure in SQL Server
body: <p>I am new to Stack Overflow as well as stored procedures. I would like to set up a procedure to include three optional parameters and three dependent parameters. If the user does not provide those optional parameters, then the result set would return all possible given the three dependent. </p>
  
  <p>In my mind it looks something similar to:</p>
  
  <pre><code>@Color1,--optional   
  @Color2,--optional    
  @Color3,--optional    
  @Date,--dependent    
  @Item,--dependent    
  @Price--dependent    
  
  IF @Color1 IS NULL OR @Color2 IS NULL OR @Color3 IS NULL    
  THEN 
      EXEC (SELECT * 
            WHERE 
                Date = @Date AND 
                Item = @Item AND 
                Price = @Price)
  ELSE 
      EXEC (SELECT * 
            WHERE 
                Color1 = @Color1 AND
                Color2 = @Color2 AND
                Color3 = @Color3 AND
                Date = @Date AND 
                Item = @Item AND 
                Price = @Price)
  </code></pre>
  
  <p>but I'm still learning. Thanks in advance for any help</p>