SQL function as default parameter value?

前端 未结 6 521
孤城傲影
孤城傲影 2020-12-13 11:45

I tried changing a default parameter value with this:

ALTER PROCEDURE [dbo].[my_sp]
@currentDate datetime = GETDATE()

and all the SQL pre-c

6条回答
  •  星月不相逢
    2020-12-13 12:28

    I don't think that is possible, you have to use a literal (constant) value as the default.

    However you can do this:

    Set @currentDate = Coalesce(@currentDate , GetDate())
    

提交回复
热议问题