(do something possibly wrong)
IF @@ERROR <> 0
BEGIN
(do something)
END
e.g.
SET @VAL = CAST( @string AS FLOAT)
IF @@ERROR <> 0
BEGIN
SET @VAL = 0
END
It generally works fine BUT if you use such a code in UDF - user defined function the code compiles just fine, but it just doesn't work. The exception is never handled and the misuse of @@ERROR is not signalled. This, as the microsofties say, is 'by design'. Too bad that the @@ERROR Books Online entry doesn't mention this fact, I had to waste a (wee) bit more time and confirm this information in somebody else's blog.
No comments:
Post a Comment