I tried changing a default parameter value with this:
ALTER PROCEDURE [dbo].[my_sp]
@currentDate datetime = GETDATE()
and all the SQL pre-compiler gave me was this error:
Msg 102, Level 15, State 1, Procedure my_sp, Line 8 Incorrect syntax near '('.
I have already created the procedure. (I'm not sure if that's relevant.) I was using a null default value and checking for that later, but that doesn't seem proper. Can I do this in one line?
Update: I was going off of
MSDN's description of stored procedure parameters:
[ = default ] Is a default value for the parameter. If a default value is defined, the function can be executed without specifying a value for that parameter.
Note:
Default parameter values can be specified for CLR functions except for the varchar(max) and varbinary(max) data types.
When a parameter of the function has a default value, the keyword DEFAULT must be specified when the function is called to retrieve the default value. This behavior is different from using parameters with default values in stored procedures in which omitting the parameter also implies the default value.
Am I reading this wrong?
Many thanks.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…