My understanding is that in a stored procedure (or any code for that
matter) if an error occurs you can detect it by checking @@error
variable and raise your own error with raiserror statement.
The problem is that the original error is not suppressed. For example
I received the following output from a stored procedure from the same
error:
Server: Msg 547, Level 16, State 1, Procedure spUpdateSecurit yMaster,
Line 49
INSERT statement conflicted with COLUMN FOREIGN KEY constraint
'FK_SM_mm_Excha nge_Exchanges'. The conflict occurred in database
'Trading', table 'Exchanges', column 'IsoCode'.
Server: Msg 50000, Level 14, State 1, Procedure
spUpdateSecurit yMaster, Line 57
Unable to insert into "SM_mm_Exchange " table
The statement has been terminated.
So why should we bother to use raiseerror if the orginal error is
going to be given to the client anyways? The end result is two error
messages.
matter) if an error occurs you can detect it by checking @@error
variable and raise your own error with raiserror statement.
The problem is that the original error is not suppressed. For example
I received the following output from a stored procedure from the same
error:
Server: Msg 547, Level 16, State 1, Procedure spUpdateSecurit yMaster,
Line 49
INSERT statement conflicted with COLUMN FOREIGN KEY constraint
'FK_SM_mm_Excha nge_Exchanges'. The conflict occurred in database
'Trading', table 'Exchanges', column 'IsoCode'.
Server: Msg 50000, Level 14, State 1, Procedure
spUpdateSecurit yMaster, Line 57
Unable to insert into "SM_mm_Exchange " table
The statement has been terminated.
So why should we bother to use raiseerror if the orginal error is
going to be given to the client anyways? The end result is two error
messages.
Comment