Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi

 

Went looking for information on how to handle errors in SQL Server 2000. I originally thought it would be as simple as putting a try catch statement around my code, like for oracle, and then specifying what errors I want to check for. However, it seems that its not that simple for SQL Server 2000.

 

What one article said is that I must declare a variable as an integer.

Declare @err as int

Then after every statement, i check the value of my variable. If the value has changed, then an error has occured otherwise nothing.

Select @err = @@error
if @err <> 0
Return @err   

 

My questions is whether this is the best way to handle exceptions in my stored procedure?

 

Mike55.

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Posted
As far as I am aware its the only way to handle errors, though you can specify your own error messages to provide more or less information before returning out of the stored procedure.

Afraits

"The avalanche has started, it is too late for the pebbles to vote"

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...