|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi,
I'm wondering if there's a means to execute a stored prodecure (or perhaps a single SQL statement) whenever an error is raised (whether manually using RAISERROR or automatically from SQL Server) for means of logging. For example, I'd like to fill a table with all raised errors, or to send an e-mail every time. Thanks in advance! |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Well, you can easily add a call to a custom logging stored procedure in
every place where you are currently doing a RAISERROR and/or TRY/CATCH. And certain error level/severity are already logged to the SQL Server error log. Do you really want to log every time I try to try to run a query and have a syntax error? Not even sure if you can lower the "log to error log" bar that low, or if you could set up some kind of event sink for it (I don't think that there is a server trigger that could capture all RAISERROR events). But if your systems and users are anything like most of the ones I deal with, even if you could do this, your logging data growth would quickly outpace your real business data, and it would likely have an extremely low signal to noise ratio. A On 6/13/08 3:00 AM, in article A14F4AF5-3C04-4820-8803-42B0AE85D4C6@microsoft.com, "Stefan Gerdts" <Stefan Gerdts@discussions.microsoft.com> wrote: > Hi, > > I'm wondering if there's a means to execute a stored prodecure (or perhaps a > single SQL statement) whenever an error is raised (whether manually using > RAISERROR or automatically from SQL Server) for means of logging. For > example, I'd like to fill a table with all raised errors, or to send an > e-mail every time. > > Thanks in advance! |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
You will have to deal with something subsequent to the procedure doing a
rollback if you are in a transaction. There is no way within TSQL to create a second seperate transaction. |
|
![]() |
| Outils de la discussion | |
|
|