Re: Transaction Abort in a trigger SQL 2008, writing to event log
- From: Erland Sommarskog <esquel@xxxxxxxxxxxxx>
- Date: Wed, 5 Aug 2009 07:19:55 +0000 (UTC)
John Couch (JohnCouch@xxxxxxxxxxxxxxxxxxxxxxxxx) writes:
I have done some stack trace type of error catching in Powerbuilder, VB
and in C# (not real good at C# though). I liked it simply because I
could see the entire call stack to see where the call originated and the
steps it went through to get to the error...etc.
Well, it would be nice to access the call stack from anywhere in SQL Server,
but alas there is no such feature. However, votes to this Connect item
are always welcome:
http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=124537
BUT, you said something about using a CLR procedure to write out to the
table or event log? I will have to look that up. I would still have to
rollback that transaction wouldn't I? Wouldn't that affect the CLR
procedure?
In the system I work with, whenever we want to raise an error or just log a
debug message we called a certain stored procedure what expands parameters,
writes the message to a log table and raises the error. But if the logging
procedure finds that there is an open transaction, it does not write
directly to the log table, but instead calls an extended stored procedure
that performs a loopback connection and writes to this table outside the
transaction. We use an XP because we devised this scheme long before there
were CLR procedures.
It should be added that using a loopback is a kludge for another missing
feature in SQL Server which exists in some other products, for instance
Oracle, that is autonomous transactions:
http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=296870
--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx
Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
.
- Follow-Ups:
- Re: Transaction Abort in a trigger SQL 2008, writing to event log
- From: John Couch
- Re: Transaction Abort in a trigger SQL 2008, writing to event log
- References:
- Transaction Abort in a trigger SQL 2008, writing to event log or t
- From: John Couch
- Re: Transaction Abort in a trigger SQL 2008, writing to event log or t
- From: Erland Sommarskog
- Re: Transaction Abort in a trigger SQL 2008, writing to event log
- From: John Couch
- Re: Transaction Abort in a trigger SQL 2008, writing to event log
- From: Erland Sommarskog
- Re: Transaction Abort in a trigger SQL 2008, writing to event log
- From: John Couch
- Transaction Abort in a trigger SQL 2008, writing to event log or t
- Prev by Date: Re: DDL Trigger Question
- Next by Date: How to create rownumber as a column
- Previous by thread: Re: Transaction Abort in a trigger SQL 2008, writing to event log
- Next by thread: Re: Transaction Abort in a trigger SQL 2008, writing to event log
- Index(es):
Relevant Pages
|