开发者

Why is DEFAULT Keyword Allowed in CREATE PROCEDURE Command

In t开发者_如何学Pythonhe following statement, the DEFAULT keyword appears where a default value is defined for a parameter.

CREATE PROCEDURE usp_Test
    @sp_param1 varchar(20) = DEFAULT
AS
    SELECT @sp_param1 AS myTest
;

NULL is assigned to @sp_param1. But, The default value must be a constant or the NULL keyword.

Why is the DEFAULT keyword allowed in this situation?


The DEFAULT keyword is a placeholder for something that you want to provide, but is not really even NULL. Most commonly seen in

exec SProcName 2, DEFAULT

Even though the 2nd param is supplied, it is not actually a value, but is an instruction to use the DEFAULT value of the 2nd param.

When used in the CREATE PROC itself, it parses, but is simply treated as NULL.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜