Transact-SQL (SQL Server 2008) 中的参数检查:IF/OR/raiseerror 语法错误
我目前有这段代码,用于检查输入变量是否在特定范围内:
IF (@vThingID < 17 OR @vThingID > 16381)
BEGIN
raiserror('Thing ID out of range: must be between 17 and 16381')
RETURN
END
这是存储过程内的 T-SQL 代码。 “编译”到存储过程时的错误消息是这样的:
消息 102,级别 15,状态 1,服务器*-,过程 np* ****,第 19 行
“)”附近的语法不正确。
我尝试过更改所有语法 - 删除括号、取出 OR 语句、在某些行后面加上分号等。它似乎没有任何区别,而且我在这里找不到任何语法错误。
I currently have this snippet of code which checks that an input variable is within a certain range:
IF (@vThingID < 17 OR @vThingID > 16381)
BEGIN
raiserror('Thing ID out of range: must be between 17 and 16381')
RETURN
END
This is T-SQL code that is inside a stored procedure. The error message, on "compiling" to a stored procedure, is this:
Msg 102, Level 15, State 1, Server *-, Procedure np*****, Line 19
Incorrect syntax near ')'.
I've tried changing all the syntax- removing the parentheses, taking out the OR statement, putting semicolons after certain lines, etc. It just doesn't seem to make any difference, and I can't spot any syntax errors here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
RAISERROR
函数的严重性和状态不是可选的。查看文档并确定哪些值对您最有意义。The severity and state of the
RAISERROR
function are not optional. Check the documentation and decide which values make the most sense for you.