Re: try catch ok, what about finally?
- From: "Mike C#" <xyz@xxxxxxx>
- Date: Mon, 13 Nov 2006 01:20:08 -0500
"JCollum" <jcollum@xxxxxxxxx> wrote in message
news:1163039479.981830.318970@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Read the TRY CATCH docs closely and you'll find that some errors are at
a level that's low enough that the catch block will ignore them. I
beliece the cutoff is 11?
Or maybe 10.
Anything that is "high" enough to trigger the
catch will also roll back the transaction and anything that it
triggered. Try your code with a RAISERROR with a level of 11 and I'm
betting that you're log won't get written out.
I'll see your 11 and RAISE you 4. It's obvious you didn't bother copying
and pasting the code, so here's another simpler example for you to pick
apart without actually "testing" per se:
CREATE TABLE #log (err NVARCHAR(2000) NOT NULL);
BEGIN TRY
RAISERROR('Error', 15, 127);
END TRY
BEGIN CATCH
INSERT INTO #log (err)
VALUES (ERROR_MESSAGE());
END CATCH
SELECT * FROM #log;
DROP TABLE #log;
What I"m wondering is if there's any way to do something in this
situation that won't get rolled back.
....
.
- Follow-Ups:
- Re: try catch ok, what about finally?
- From: JCollum
- Re: try catch ok, what about finally?
- References:
- try catch ok, what about finally?
- From: JCollum
- Re: try catch ok, what about finally?
- From: Mike C#
- Re: try catch ok, what about finally?
- From: JCollum
- try catch ok, what about finally?
- Prev by Date: Re: Delete records from database older than "x" number of days
- Next by Date: how to ? automated sql server backup from hosted server
- Previous by thread: Re: try catch ok, what about finally?
- Next by thread: Re: try catch ok, what about finally?
- Index(es):
Relevant Pages
|