>>>>>Can I raise an exception from within a SP? If yes, how?
>>>>>
>>>>>Einar
>>>>>
>>>>>UPDATE: Is RAISEERROR the correct way to go about this?
>>>>
>>>>Yes.
>>>
>>>Thanks Sergey. It seems like I will keep you busy today :)
>>
>>Warning: RAISEERROR doesn't stop the SP execution
>
>Thanks for warning me Fabio. That was my follow-up question for Sergey. (I guess I kinda noticed that because in the documentation they put ROLLBACK after RAISERROR).
>How would you solve the problem of getting the SP to stop execution? Would you use GOTO?
>
>Something like this:
>
>UPDATE myTable SET Name=@Name1 WHERE Id=@Id1
>IF @@ROWCOUNT=0
>BEGIN
> RAISERROR('Error 1',16,1)
> GOTO WhereRollBackIs
>END
>
>UPDATE myTable SET Name=@Name2 WHERE Id=@Id2
>IF @@ROWCOUNT=0
>BEGIN
> RAISERROR('Error 2',16,1)
> GOTO WhereRollBackIs
>END
>
>UPDATE myTable SET Name=@Name3 WHERE Id=@Id3
>IF @@ROWCOUNT=0
>BEGIN
> RAISERROR('Error 3',16,1)
> GOTO WhereRollBackIs
>END
>
>COMMIT TRANSACTION
>
RETURN
>WhereRollBackIs:
> ROLLBACK TRANSACTION
>
>
>Please let me know if you see anything (really) bad.
>
>Einar