Hello everyone,
First I apologise if this has been asked. I did a quick search and didn't find anything related.
Here is my scenario. I tried to do this:
ALTER PROCEDURE [dbo].[my_sp]
@currentDate datetime = GETDATE()
All the SQL pre-compiler gives me back is this error: Msg 102, Level 15, State 1, Procedure my_sp, Line 8 Incorrect syntax near '('.
I have already created the procedure. I was using a null default value and checking for that later but it doesn't seem proper. Can I do this in one line?
UPDATE: First thank you all for the quick responses. Holy cow! Second I was going off of MSDN's description of stored procedure parameters here: http://msdn.microsoft.com/en-us/library/ms186755.aspx
[ = 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.
Did I read this wrong? Many thanks.
UPDATE 2: Replied to two answers with comments. Not sure if they should go up here.