|
-
Jun 5th, 2008, 08:35 AM
#1
Thread Starter
Hyperactive Member
ERROR_MESSAGE() not returning RaiseError's message
I'm running a stored procedure (SQL Server 2005) that's doing an Insert Into a table.
The table has a trigger that is using RaiseError because a value is invalid.
The problem:
When I run the stored proc directly in the Management Studio
it returns a "canned" SQL error message in the Messages window,
plus the errmsg from the trigger's RaiseError.
This is great because it give me nice detail.
But, I want to capture that error info in a table to send to myself.
So, I added
BEGIN TRY
-- code
END TRY
BEGIN CATCH
-- get all the error info
END CATCH
However, the ERROR_MESSAGES() function only returns the canned SQL msg,
NOT the msg from the trigger's RaiseError.
So, now I've lost the detail.
Any idea how I can get the triger's error?
I don't own the trigger, so edting that isn't an option.
Thanks, DaveBo
"The wise man doesn't know all the answers, but he knows where to find them."
VBForums is one place, but for the really important stuff ... here's a clue 1Tim3:15
-
Jun 5th, 2008, 09:01 AM
#2
Re: ERROR_MESSAGE() not returning RaiseError's message
What does your catch look like?
-tg
-
Jun 5th, 2008, 11:40 AM
#3
Thread Starter
Hyperactive Member
Re: ERROR_MESSAGE() not returning RaiseError's message
Code:
BEGIN CATCH
INSERT INTO AA_ErrorLog (
ErrSource, ErrLine, ErrNum, ErrMsg, Az_ID, Last_Name, First_Name)
VALUES(
ERROR_PROCEDURE(), ERROR_LINE(), ERROR_NUMBER(), ERROR_MESSAGE(),
IsNull(@AZ_ID,'NULL'), IsNull(@LastName,'NULL'), IsNull(@FirstName,'NULL') )
END CATCH
"The wise man doesn't know all the answers, but he knows where to find them."
VBForums is one place, but for the really important stuff ... here's a clue 1Tim3:15
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|