我有这个存储过程:
CREATE PROCEDURE [dbo].[get_test_status]
@CreatedBy INT OUTPUT,
@TestStatusId INT OUTPUT,
@UserTestId INT,
@UserId INT
AS
如果@UserId参数为null或零,如何引发错误?
这是我尝试过的方法,但它给出了语法错误:
IF (@UserId = 0 OR @UserId IS NULL)
THROW 70001, "UserId: Cannot be zero or null" , 1
我想你已经错过了; -冒号
IF (@UserId = 0 OR @UserId IS NULL)
THROW 70001, "UserId: Cannot be zero or null" , 1;
编辑:您应该使用'-单引号
IF (@UserId = 0 OR @UserId IS NULL)
THROW 70001, 'UserId: Cannot be zero or null' , 1;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句