1

I have a stored procedure that I would like to run from a simple button click. The stored procedure takes 5-10 mins to run direct from SMSS.

I'm not looking to return any results to the browser, so I would prefer if the browser didn't hang whilst the stored procedure was running. I'm using the following to trigger the SP on button click.

$sp_exec = "EXEC [sp_name]";
$sp_exec_qry = sqlsrv_query($conn, $sp_exec];

Is there a way to stop php waiting for the script to finish? to background it somehow? Apologies if this is very amateur, just learning as I go :) Thanks

New contributor
SteveClose is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
5
  • 1
    Seems like you need an asynchronous process
    – Thom A
    Commented 2 days ago
  • 3
    Have you considered executing the stored procedure from a SQL Agent job step and just having your PHP page start the job? Commented 2 days ago
  • 1
    Implement a javascript function so button just posts somewhere and use callbacks from that to handle the results. Commented 2 days ago
  • @AlwaysLearning Worked a treat! Thank you so much!
    – SteveClose
    Commented 2 days ago
  • The only problem is that you don't know when the job is finished since it's ran async Commented 11 hours ago

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.