How to exit the stored procedure imdiatly?

  • Good morning you all!

    I have two stored procedures. The first one is formats and prepares all the necesary information request and pass them to the second stored procedure to insert to a different tables, creates reports and exports to different files format. This

    stored procedure will take a minute or 2 to completed all assign task.

    Here is what I do really wanted it to do in the first stored procedure. It fire the second stored procedure and does the very next task without waiting for the second stored procedure to finish?

    I wish if there is anything in SQL-2K has some command like: Execute usp_StoreProcedure1(@strParam1,@intParam2,@dtDateVisit) NOWAIT

    but I have failed to look for one.

    Any you of you out there have any suggestion how to do it. I am out of mind at this point.

    Thank you all.

    Tin le

    Tin Le


    Tin Le

  • There is no simple way of doing this within a stored procedure as the second procedure is nested within the first and the first will not continue until the second has completed.

    One way to do this for the first proc to create a job which does the same as the second procedure. The first proc would also start the job and will then complete. The job will continue as a separate process until it completes. If need be, you can delete the job when it is complete.

    An alternative is to have a table into which the first proc inserts a row and then completes. There would be a job which monitors the table for an appropriate row every n seconds and when it finds a row it then continues and executes the second proc.

    Jeremy

  • First, thank you very much for your prompt answer. I am really appreciated that.

    I already have implemented a job to monitor the process using time control as what you have suggested. This one could do the same, but that is not what I am after with:

    How about: use Master..xp_cmdShell to excute the second stored procedure by using OSQL in the batch command. But how? Is there anyone have any suggestion?

    Tin Le


    Tin Le

  • XP_cmdshell should work. I typically use the solution Jeremy suggests.

    Andy

    http://www.sqlservercentral.com/columnists/awarren/

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply