Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Get the trigger name that is failing

Posted on 2011-09-22
3
Medium Priority
?
181 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 5

Assisted Solution

by:zvytas
zvytas earned 375 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 375 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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

721 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