How to restrict NULL as parameter to stored procedure SQL Server?

前端 未结 5 1531
孤独总比滥情好
孤独总比滥情好 2020-12-09 14:52

Is it possible to create a stored procedure as

CREATE PROCEDURE Dummy 
    @ID INT NOT NULL
AS
BEGIN
END

Why is it not possible to do somet

5条回答
  •  轮回少年
    2020-12-09 15:26

    Your code is correct, sensible and even good practice. You just need to wait for SQL Server 2014 which supports this kind of syntax.

    After all, why catch at runtime when you can at compile time?

    See also this Microsoft document and search for Natively Compiled in there.

    As dkrez says, nullability is not considered part of the data type definition. I still wonder why not.

提交回复
热议问题