Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
MyronCope
Starting Member
46 Posts |
Posted - 2010-06-18 : 08:45:57
|
using sql server 2005.I have a trigger set up so when a user tries to add a new email and there is no matching teamID then it will do a "raisError", when the team does not exist (if stmt) then the following will happen in the trigger: ROLLBACK TRANRaisError('The Team Does Not Exist in our system. Please Enter a Valid Team.', 16, 1)The problem is that in addition to the error text I am also displaying the following text (inside the <error>) to the system user:<ERROR>...The transaction ended in the trigger. The batch has been aborted.</ERROR>I do not want to show the "the trans...batch has been aborted" text, does anyone know how to hide this extra text? I assume that I need to change the "16" to be something else?thanks |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2010-06-18 : 09:31:27
|
| As long as you do a ROLLBACK in the trigger you'll get that message. |
 |
|
|
MyronCope
Starting Member
46 Posts |
Posted - 2010-06-18 : 10:01:49
|
quote: Originally posted by robvolk As long as you do a ROLLBACK in the trigger you'll get that message.
thanks, I think I will just look for my starting error text in my application and if I see that throw an exception with only my error text (leaving out the "batch abort" stuff) and the else part of the if stmt will just be to throw the exception.Not a perfect solution but one that will work. |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2010-06-18 : 10:35:10
|
We take care of those sort of "invalid data" issues in the Sproc that saves the data, thus such data should never reach the database. Our Sproc return an error code to the application, as well as a nice friendly message 9which the application can display to the user)Whereas a trigger is a bit of a blunt weapon - all it can do to stop the data hitting the DB is to ROLLBACK We may also have data-validity tests in the TRIGGER too, with a ROLLBACK (which will screw up the application just as you have described) but that point in the trigger should never be reached unless something else mucks up. |
 |
|
|
|
|
|