Trigger SQL Stored procedure WITHOUT waiting for it to return?

  • Goal: I have a button that triggers a stored procedure in SQL, that can take several minutes. The user does not need to wait at all to know that it completed, in fact, they'd rather click the button, change the inputs, and trigger another thread of this stored proc.
  • there is no data that needs to be returned, it is just processing data updates in the background to the collection of rows designated by the query.
  • Steps: right now I have everything working, but I get the timeout error when a query runs for longer than 2 minutes. I tried using a JS query to call the query with await but then realized that's the opposite of what I want. Can't figure out how to just have it trigger, maybe wait 2 seconds to confirm no ERROR came back, and then carry on.

this is the entire contents of my SQL query:
exec snow_sales.Regen_Holograms_by_ITEMSK @item_sk={{ aItemPart.value }}

1 Like

Hey @Stuart - welcome back to the forum!

I've seen different solutions to this, depending on the SQL platform and whether the procedure needs to take in parameters or not. The best-fitting solution is probably setting up a Service Broker, but I think this is limited to MS SQL Server?

There's likely a raw JS solution that involves wrapping the query.trigger function in a Promise, though! Something like this:

After writing that, I'm pretty sure you could also just run setTimeout(query.trigger, 1). If you wanted error handling, though, you'd want to use code similar to the above. Hopefully that helps!