Solved

Get the trigger name that is failing

Posted on 2011-09-22
3
175 Views
Last Modified: 2012-05-12
Hi there

A customer of mine has a table with 11 triggers that fires for inserts, updates and deletes. One of these triggers fails and an error message is displayed, unfortunately it doesn't point me to the trigger that is causing the error. Is there any way I can see which trigger it is that causes the error message ? Can I run  a query and get hold of this information  ? I know it's not good practise to have so many triggers on one table but that's not my idea.
0
Comment
Question by:Mackey_man
3 Comments
 
LVL 5

Assisted Solution

by:zvytas
zvytas earned 125 total points
ID: 36580459
Error message should contain some details about the trigger that is failing. Providing error message would be helpful.
Another way to solve this is disabling triggers one by one and trying to insert/update/delete data. It can take a while, but would allow to solve the problem. Disabling a trigger can be done with the following SQL statement:

DISABLE TRIGGER <trigger name> ON <table name>

Enabling trigger can be done as follows:

ENABLE TRIGGER <trigger name> ON <table name>
0
 
LVL 5

Accepted Solution

by:
eridanix earned 125 total points
ID: 36890203
Hi,

if you can edit triggers, you can add error condition, which can you tell in which trigger or triggers throws error.
To the end of each trigger add for example:

IF @@ERROR <> 0
BEGIN
        INSERT INTO dbo.SomeLogTable (error) VALUES ('name_of_trigger')
END

More information here:
http://msdn.microsoft.com/en-us/library/aa933181%28v=sql.80%29.aspx
http://www.sqlteam.com/article/an-introduction-to-triggers-part-i
0
 

Author Closing Comment

by:Mackey_man
ID: 36891484
Thanks for taking the time to help me.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question