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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-02-09 : 09:39:30
|
| Harold writes "I'm trying to incorporate error handling into a SP. I have been testing with this small SP. I have two errors in it. When ran as presented below, the 1st error is trapped as expected, but the 2nd error causes a fatal error and is stopped in debug mode.However, when I revserse the two errors (run Error 2, then error 1) it works throughout the SP.Any ideas?Thanks for looking.Harold Scott./*----------------------------------------------*/SET QUOTED_IDENTIFIER ONSET ANSI_NULLS ONgoalter procedure sp_RecalcRetention @Rc1 int, @Rc2 int asBegindeclare @Id int, @L int, @iError int SET NOCOUNT ON Set @Id=@Rc1 select @iError=@@Error--ERROR 1 select convert(datetime,'20033123') select @iError=@@Error set @Id=@L--ERROR 2 (cstatus is char(1)) update item set cstatus='1234' where id=30 select @iError=@@Error set @Id=@LReturn (0)end" |
|
|
Kristen
Test
22859 Posts |
Posted - 2006-02-09 : 11:53:35
|
| I think you are going to struggle to "catch" errors like these within SQL Server.You might be able to catch them from a wrapper SProc (i.e. one that calls your Sproc, and then checks for Success/Failure), but that's about it IME.SQL2005 may offer more in this regard (I have no experience of it as yet)Kristen |
 |
|
|
|
|
|