Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Failure to return RaiseError message during Update Transaction

Status
Not open for further replies.

RobS23

Programmer
Jun 4, 2001
161
GB
I am trying to trap an conversion error arising from running the following update against 'myField' which is a decimal.

However, rather than continue into my trap the transaction breaks and returns the standard error message

Server: Msg 8114, Level 16, State 5, Line 1
Error converting data type varchar to numeric.


Naturally, I'm being an idiot but just what have I forgotten over the past six months!??!


DECLARE @ErrorExit INT
SET @ErrorExit = 0

begin transaction


UPdate DTS_Imports set myField = 'DontLikeText'

IF @@ERROR <> 0

begin

ROLLBACK Transaction
RAISERROR
('Process Failed',
16, 1)

end

Commit Transaction

go

Server: Msg 8114, Level 16, State 5, Line 1
Error converting data type varchar to numeric.
 
Error levels of 16 and over will automatically stop the processing of the current batch, therefore your error-trapping code never gets reached.

--James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top