Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Stored Procedure containing steps Attachments

Author  Topic 

sand-lakes1
Starting Member

29 Posts

Posted - 2002-11-07 : 08:50:57
Imagine I create a stored procedure containing several
steps. For example 7 steps. What can I do to solve
following problem:

"Step 1 and 2 succeeded; step 3 fails ...."

What actions do I have to take to go to step 4 instead of
canceling the stored procedure. Or is this not possible
and do I have to create many sp's and put them in a job ?

thanks in advance

John
.



nr
SQLTeam MVY

12543 Posts

Posted - 2002-11-07 : 09:09:35
Think about what you are trying to cater for.

step 3 fails - how does it fail.
If it aborts the connection (quite possible) then there is nothing you can do in the SP or the agent - you will need to code in and external application like VB or DTS to carry on.

Another option is to create a scheduling process.
Put the steps into a table and use the agent to call an SP to call them. The table is updated with (executing before the call) the success/failure of the step and then goes on to the next one. If the connection aborts then the next call will see that one was executing - update that to failed and go on to the next.

OK the articles I was meant to submit on a more advanced version of this are well overdue.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

SamC
White Water Yakist

3467 Posts

Posted - 2002-11-07 : 09:10:59
You can use

IF <condition> BEGIN


END
ELSE BEGIN


END

Sam

Go to Top of Page
   

- Advertisement -