You are here: Re: Sql Server incorrectly functioning « MsSQL Server « IT news, forums, messages
Re: Sql Server incorrectly functioning

Posted by Erland Sommarskog on 05/27/05 00:01

Erland Sommarskog (esquel@sommarskog.se) writes:
> Steve (fizzy1236@yahoo.com) writes:
>> Thanks, I will give a good read through and rework this. Not too happy
>> with Microsoft's documentation, as they state I should be able to do
>> this. From Sql Server Books Online...
>>
>> -- Save any non-zero @@ERROR value.
>> IF (@@ERROR <> 0)
>> SET @ErrorSave = @@ERROR
>>
>> Found in the using @@ERROR section.
>
> See below for a link to an updated version of Books Online. It is indeed
> an embarrssing error. But the same section also says:
>
> Because @@ERROR is cleared and reset on each statement executed, check
> it immediately following the statement validated, or save it to a local
> variable that can be checked later.

By the way, while I don't want to embarrass you, I would like to point
out that this mishap could have been avoided if you had tested the
error handling, before you spread it all over town. Error-handling code
is one that is often over-looked when testing, but good testing should
also cover some error cases to see that they are handled well.

On a completely other note: SQL 2005 gives you exception handling with
TRY-CATCH syntax, which makes error handling in SQL 2005 a lot more
pleasant.


--
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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация