|
Posted by Erland Sommarskog on 05/25/05 23:10
Steve (fizzy1236@yahoo.com) writes:
> I have a .NET application with a sql server database backend. Our
> client has been having problems lately with data being returned from
> the database with wrong data. We have error logging in our stored
> procedures and even this is reporting wrong. In every stored procedure
> we have the following:
>
> IF @@Error <> 0
> BEGIN
> EXEC dbo.HandleError
> @ErrorNum = @@Error,
> @ProcID = @@PROCID
> END
I've bad news for you: you have lots of stored procedures to edit.
@@error is set after each statement, and that includes IF. So by the
time execution reaches the EXEC statement @@error is 0.
I have an article on my web site about error handling in stored procedures
that you may find useful, http://www.sommarskog.se/error-handling-II.html.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp
Navigation:
[Reply to this message]
|