Solved

RAISERROR

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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
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…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

895 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now