We have a stored procedure in which there are two parts. In part 1, failures need to be returned to the application, and the part must be completely executed before the stored procedure returns.
Part 2 is a long process which needs to execute whenever the procedure is called, but all failures can be ignored (or handled elsewhere), however we want the application to return before it is completed. SO we need a procedure that does this:
exec PART1
return
exec PART2 -- still gets executed, but after sql server has already responded that the SP was a success to the client.
I thought we could potentially do this as a 'worker thread', though I don't know any syntax to do this in SQL server.
Any ideas? Am I on the right track? Do you know the syntax to accomplish this? Am i overlooking some sort of easier way to accomplish this?