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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

use of raiserror

Status
Not open for further replies.

mp89

Programmer
Sep 17, 2004
35
GB
I want to raise an error in my stored procedure and then have the code go to a specific part of the sproc to deal with errors before exiting. Is this the right way to go about doing this?

e.g.

if (condition)
begin
rollback tran
raiserror
goto on_error
end

--other stuff

on_error:
set @result = 0
return @result


Cheers,

Mike
 
That should work for you, assuming that you raise the correct severity level so that the batch doesn't stop executing. You'll need the correct syntax for Raiserror of course.

Denny

--Anything is possible. All it takes is a little research. (Me)

[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top