Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

how to know whether a stored procedure run successfully or not Expand / Collapse
Author
Message
Posted Tuesday, May 5, 2009 10:36 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, May 14, 2012 2:54 AM
Points: 162, Visits: 78
Hi Everybody,

Can any one help me in finding whether a stored procedure run successfully or not. I am using sql server 2000. I am calling a sp in another sp. Basing on the status of the innner sp i need to do some operations.

Thanks in advance.


Who is wise? He that learns from everyone. Who is powerful? He that governs his passions. Who is rich? He that is content. Who is that? Nobody.:)
Post #710812
Posted Wednesday, May 6, 2009 6:11 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Sunday, November 4, 2012 12:23 PM
Points: 2,087, Visits: 3,932
Hi

It depends on how your inner procedure returns that something was not successfully. Your inner procedure can return a return code which can be handled in your outer procedure.

Greets
Flo



The more I learn, the more I know what I do not know
Blog: Things about Software Architecture, .NET development and T-SQL

How to Post Data/Code to get the best Help How to Post Performance Problems
Post #710976
Posted Wednesday, May 6, 2009 8:14 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 1:28 PM
Points: 11,157, Visits: 12,897
Here is a simple example:

DECLARE @retval INT

EXEC @retval = sys.sp_who

IF @retval = 0 -- success
BEGIN
PRINT 'Success'
END
ELSE
BEGIN
PRINT 'Failure'
END

By default stored procedures return 0 for success, but you can specify any integer for the return value based on whay happend in your stored procedure.




Jack Corbett

Applications Developer

Don't let the good be the enemy of the best. -- Paul Fleming

Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
Post #711111
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse