Executing batches asychronously?

  • Say I have a procedure inside which I have the task of sending out emails...this may be another procedure or a batch of statements. Can I run this separately without my main batch processing not waiting or blocking for this task?

  • No. You can only do this by having a job that runs (say every 5 minutes) to send the emails or execute other batch proceses.

    Jez

  • You could use the sp_add_job to create a job which deletes itself after running and then execute it using sp_start_job.



    Nuke the site from orbit, its the only way to be sure... :w00t:

  • "Create a job which deletes itself..."???!

    Explain.

  • The syntax for sp_add_job has a parameter called @delete_level. If you use this you can set the job to delete itself on completion (wether it is successful or not).

    You will need to look at sp_add_job,sp_add_jobstep & sp_start_job. (all in msdb)

    Quickest and easiest way to work all this out is to run sql profiler filtered by your username and create a job in enterprise manager. It will give you all the code you need. Job explore the options a little more to make sure your getting everything you want.



    Nuke the site from orbit, its the only way to be sure... :w00t:

  • Arun,

    Has this helped?



    Nuke the site from orbit, its the only way to be sure... :w00t:

Viewing 6 posts - 1 through 5 (of 5 total)

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