Execute a stored procedure from ASP page, but don't wait for it to complete?

Discussion in 'ASP General' started by Richard Morey, Jan 21, 2004.

  1. Hi..

    I have written a stored procedure that take 5 - 8 minutes to fully execute..
    I wrote this routine as a stored procedure because I started to create all
    the functionality via ASP but I kept getting time out errors on my ASP page.
    The problem is that when I call the stored procedure from the ASP page the
    server waits for the procedure to complete before returning the ASP page..
    Is there any way to avoid this? I would like the user to be able to trigger
    the stored procedure and have the page returned right away..

    Thanks,

    Rich
    Richard Morey, Jan 21, 2004
    #1
    1. Advertising

  2. Richard Morey

    Bob Barrows Guest

    Richard Morey wrote:
    > Hi..
    >
    > I have written a stored procedure that take 5 - 8 minutes to fully
    > execute.. I wrote this routine as a stored procedure because I
    > started to create all the functionality via ASP but I kept getting
    > time out errors on my ASP page. The problem is that when I call the
    > stored procedure from the ASP page the server waits for the procedure
    > to complete before returning the ASP page.. Is there any way to avoid
    > this? I would like the user to be able to trigger the stored
    > procedure and have the page returned right away..
    >

    Use SQL Agent to schedule the procedure to run as a job. Disable the job.
    This is well-documented in Books Online

    Then call the sp_start_job system stored procedure from ASP to start the
    job. The job will run asynchronously.

    The login you are using to connect from ASP will need to be granted
    permissions to run that system stored procedure.

    HTH,
    Bob Barrows
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
    Bob Barrows, Jan 21, 2004
    #2
    1. Advertising

  3. Richard Morey

    Chris Guest

    have you tried the command objects adAsyncExecute parameter on execute

    objCmd.Execute, , adAsyncExecut

    I don't know if it works, but it is a parameter option.
    Chris, Jan 21, 2004
    #3
  4. Hello,

    This worked! Thanks..

    Rich

    "Chris" <> wrote in message
    news:...
    > have you tried the command objects adAsyncExecute parameter on execute?
    >
    > objCmd.Execute, , adAsyncExecute
    >
    > I don't know if it works, but it is a parameter option.
    Richard Morey, Jan 22, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. FireListen
    Replies:
    1
    Views:
    481
    James J. Foster
    Jun 27, 2003
  2. TJS
    Replies:
    2
    Views:
    668
    Kevin Spencer
    Feb 11, 2004
  3. Jeff Thur
    Replies:
    2
    Views:
    1,010
    Guest
    Feb 7, 2005
  4. Replies:
    3
    Views:
    878
  5. Mike P
    Replies:
    0
    Views:
    3,274
    Mike P
    Jun 19, 2006
Loading...

Share This Page