Here is my code:
USE [xxx]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[problemParam]
@StartDate INT = CONVERT(INT,(CONVERT(CHAR(8),GETDATE()-130,112))),
@EndDate INT = NULL
AS
BEGIN
SSMS is not too happy with the default value I've used - in the MSDN DEFINITION HERE it says that the default value needs to be a constant rather than a variable.
Is CONVERT(INT,(CONVERT(CHAR(8),GETDATE()-130,112))) a variable or a constant? It's not a variable in the traditional way I think of a variable but then again it's not a constant like '03 jan 2013' is.
How do I get around this? Move CONVERT(INT,(CONVERT(CHAR(8),GETDATE()-130,112))) to the client that is calling the stored procedure?
EDIT
Possible duplicate as I've just spotted this SO POST
GETDATE()varies by time so it cannot be constant. Use NULL/a magic value for a default, detect it & assign your expression should it match.GETDATE()is evaluated when it is called and then constant. See these blog posts - sees to be debatable