mike55 Posted April 29, 2005 Posted April 29, 2005 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. Quote 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)
Afraits Posted May 4, 2005 Posted May 4, 2005 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. Quote Afraits "The avalanche has started, it is too late for the pebbles to vote"
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.