title: Parameter checking in Transact-SQL (SQL Server 2008): IF/OR/raiserror syntax error
body: <p>I currently have this snippet of code which checks that an input variable is within a certain range:</p>
  
  <pre><code>IF (@vThingID &lt; 17 OR @vThingID &gt; 16381)
  BEGIN
      raiserror('Thing ID out of range: must be between 17 and 16381')
      RETURN
  END
  </code></pre>
  
  <p>This is T-SQL code that is inside a stored procedure. The error message, on "compiling" to a stored procedure, is this:</p>
  
  <blockquote>
    <p>Msg 102, Level 15, State 1, Server <strong>*<em>-</strong>, Procedure np</em><strong><em>*</em>**<em>*</em>*</strong>, Line 19<br>
    Incorrect syntax near ')'.</p>
  </blockquote>
  
  <p>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.</p>