Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Whenever sqlerror goto ....

Author  Topic 

chm1234
Starting Member

1 Post

Posted - 2007-06-05 : 03:52:04
I'm new in programming with SQL ...

I try to use the "whenever sqlerror goto label" with Sql Server 2000, but it doesn't work:

whenever sqlerror goto erreur;

erreur:


The error is:
Serveur: Msg 2812, Level 16, State 62
Unable to find procedure "whenever"

It seems that the "whenever" clause is not recognized, but I don't understand.

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-06-05 : 03:59:36
Try Whichever instead of Whenever...Just kidding

There is no structured way of error handling in SQL Server 2000.

The only way is to check the value of @@ERROR variable and raise an error like this:

IF @@Error <> 0
Begin
Raiserror('some error text',16,1)
return
End

Note that you should add this check after every statement, not just at the top of the SP.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -