title: How to declare a paramater with default value (previous date) in a Stored Procedure?
body: <p>I want to set default params in a stored procedure as follows:</p>
  
  <pre><code>ALTER PROCEDURE [rpt].[STAT05] --@StartDate = '2017-08-15', @EndDate = '2017-08-16'
  
      @StartDate      DATETIME2 = DATEADD(DAY, -2, GETDATE()) 
      ,@EndDate       DATETIME2 = DATEADD(DAY, -1, GETDATE()) 
  
  AS
  BEGIN
  </code></pre>
  
  <p>,which however returns:</p>
  
  <blockquote>
    <p>Must declare the scalar variable "@StartDate".</p>
  </blockquote>
  
  <p>What's wrong with that statement?</p>