Solved

RAISERROR

Posted on 1998-11-09
3
1,713 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 20 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

820 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