I tried to change the default parameter value as follows:
ALTER PROCEDURE [dbo].[my_sp] @currentDate datetime = GETDATE()
and the whole SQL precompiler gave me this error:
Msg 102, Level 15, State 1, Procedure my_sp, Line 8 Invalid syntax near '('.
I have already created this procedure. (I'm not sure if this is relevant.) I used a default value of zero and checked it later, but that doesn't seem right. Can I do this on one line?
Update: I left the
MSDN Stored Procedure Parameter Description :
[= default] The default value for the parameter. If a default value is specified, the function can be executed without specifying a value for this parameter.
Note:
Default parameter values โโcan be specified for CLR functions, with the exception of the varchar (max) and varbinary (max) data types.
If the function parameter has a default value, the DEFAULT keyword must be specified when the function is called to get the default value. This behavior is different from using parameters with default values โโin stored procedures, in which omitting a parameter also implies a default value.
Am I reading this wrong?
Thank you very much.
sql sql-server stored-procedures
user58044 Jan 22 '09 at 20:25 2009-01-22 20:25
source share