I want to know why I can't set default value to SP datetime parameter to getdate() as below :
Create PROCEDURE [dbo].[UPILog]
(
@UserID bigint,
@ActionID smallint,
@Details nvarchar(MAX) = null,
@Created datetime = getdate()
)
if I try to save it will give me a compiler error
Msg 102, Level 15, State 1, Procedure UPILog, Line XX
Incorrect syntax near '('.
EDIT : I know that i can do it like below
Create PROCEDURE [dbo].[UPILog]
(
@UserID bigint,
@ActionID smallint,
@Details nvarchar(MAX) = null,
@Created datetime = null
)
AS
if @Created is null
SET @Created=getdate() ...