August 25, 2009 at 7:21 am
I'm using a RAISERROR and it's working perfectly. My code is:
IF @newtotal < @oldtotal
BEGIN
RAISERROR
(N'New total usage less than old total usage.',16,1)
ROLLBACK TRANSACTION
RETURN
END
[/code]
My question is, when this error is generated in my application, it says: "User database error: [Microsoft][ODBC SQL Server Driver][SQL Server]New total usage less than old total usage."
Is there a way to not show the first part of that error and only show "New total usage less than old total usage."
August 25, 2009 at 11:25 am
The problem is in your code, not in the TSQL. You have to be able to retrieve the error message from the error.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
August 25, 2009 at 6:05 pm
Assuming you are calling the Stored Procedure from within a try..catch block in your application (C#, VB) and the Procedure returns an error, you can catch the SqlException and simply retrieve the Message property on that object. This should contain the message you want.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply