You are here: Re: how to quit an sproc « MsSQL Server « IT news, forums, messages
Re: how to quit an sproc

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация