Solved

RAISERROR

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

771 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

10 Experts available now in Live!

Get 1:1 Help Now