Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

RAISERROR

Posted on 1998-11-09
3
Medium Priority
?
1,729 Views
Last Modified: 2008-03-03
I've defined error message 60001, using sp_addmessage.  An event has occurred in my stored procedure which
causes  the following lines of my code to run
   RAISERROR (60001, 16, 1) WITH SETERROR
   RETURN

On my (Database) side everything went according to plan - the process stopped and I have verified that
@@error contains 60001.  Now

1.  On the application developer's side (they'll be the ones calling the stored procedure) will they just
need to check to verify that @@error = 0 when the procedure terminates to know that the process was
successful?
2.  On the database side, is there a way to see the current contents of the sysmessages table?
3.  I know that state in an error message has no direct relevance to SQL server - has anyone found a
particularly good use for it?
0
Comment
Question by:scarlett
  • 2
3 Comments
 
LVL 2

Expert Comment

by:aliciaam
ID: 1091127
Just under Master database run:
select * from sysmessages

Good question: the state is set to false or true depending upon you want that error to be logged.

if you want to change the state of an error run:
sp_altermessage 60001, with_log, false
If you need to alter the state of a message on the sysmessages table you could use that sp.
0
 

Author Comment

by:scarlett
ID: 1091128
Thank you for answer question #2.  

I still urgently need an answer for question #1.

My question (3) about state had nothing to do with changing the state - it was an inquiry to determine if anyone has put this feature to good use and would like to share this information with a new SQL programmer.
0
 
LVL 2

Accepted Solution

by:
aliciaam earned 60 total points
ID: 1091129
When an error is raised, the error number is placed in the global variable @@ERROR, which stores the error number most recently generated by the system.  So... nothing guarantees you that @@error will be zero, it could be different than your 60001 but not necessarily zero.
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question