|
Posted by Erland Sommarskog on 06/07/07 13:59
(rshivaraman@gmail.com) writes:
> I am doing a check and on failing, i have a raiseerror command.
> I was assuming, once proc reaches raiseerror, it would stop the proc,
> but i see that the proc gives me an error message, but continues to
> run thru all the rest of the steps after raiseerror.
> how do i make the proc quit after reading raiseerror, only thru
> labels ?
Which version of SQL Server are you using?
In SQL 2000 you will need to use the RETURN statement. Preferrably you
return a value > 0, so that the caller knows that things went wrong.
On SQL 2005 you can embed the code in BEGIN TRY END TRY, and then in
BEGIN CATCH END CATCH have some generic error handling, including a
RETURN statement.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Navigation:
[Reply to this message]
|