title: T-SQL - Return custom error message and end query
body: <p>I have a lengthy stored procedure in which I would like to do something like the following:</p>
  
  <pre><code>IF @SubPageDirectory IS NULL
  BEGIN
      RAISERROR('@SubPageDirectory cannot be NULL', 10, 1)
      EXIT STORED PROCEDURE
  END
  </code></pre>
  
  <p>Basically I wish to check whether my variable is <code>NULL</code>, 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?</p>