Solved

RAISERROR

Posted on 1998-11-09
3
1,721 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Suggested Solutions

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

752 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