开发者

T-SQL - Return custom error message and end query

开发者 https://www.devze.com 2023-01-07 02:28 出处:网络
开发者_如何学GoI have a lengthy stored procedure in which I would like to do something like the following:

开发者_如何学GoI have a lengthy stored procedure in which I would like to do something like the following:

IF @SubPageDirectory IS NULL
BEGIN
    RAISERROR('@SubPageDirectory cannot be NULL', 10, 1)
    EXIT STORED PROCEDURE
END

Basically I wish to check whether my variable is NULL, and if it is, return an error message to my .NET Web Application, and stop running the query at that stage. How can I achieve this?


IF @SubPageDirectory IS NULL 
BEGIN 
    RAISERROR('@SubPageDirectory cannot be NULL', 16, 1) --change to > 10
    RETURN --exit now
END 
0

精彩评论

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

关注公众号