How can I exit the center of a stored procedure?
I have a stored procedure where I want to help out earlier (when trying to debug). I tried calling RETURN and RAISERROR , and sp continues to work:
CREATE PROCEDURE dbo.Archive_Session @SessionGUID uniqueidentifier AS print 'before raiserror' raiserror('this is a raised error', 18, 1) print 'before return' return -1 print 'after return' [snip]
I know that it works because I again encounter an error. I do not see any of my prints . If I comment on the main part of the stored procedure:
CREATE PROCEDURE dbo.Archive_Session @SessionGUID uniqueidentifier AS print 'before raiserror' raiserror('this is a raised error', 18, 1) print 'before return' return -1 print 'after return'
Then I will not get my error, and I see the results:
before raiserror Server: Msg 50000, Level 18, State 1, Procedure Archive_Session, Line 5 this is a raised error before return
So the question is: how can I get rid of the stored procedure in SQL Server?
sql-server tsql stored-procedures sql-server-2000 flow-control
Ian Boyd Dec 07 '09 at 21:03 2009-12-07 21:03
source share