I have a stored procedure that is triggered to reload a table of data every 5 minutes. It takes approx 2-3 seconds to execute.
I was just wondering what happens if an end user tries to view whats in the table (excel file that selects from table) at exactly the point the script is running. i.e. after deleting from the table and before finishing the reload.
What will they see? I guess the scenarios are:
1) The select from table statement executes and retrieves whatever is in the table at that exact point.... a mess of data.
2) It will wait and execute once the procedure is finished.
3) It will take the data that was in the table right before the procedure started.
I would like it to wait for the procedure to finish. What can I do to ensure that is what happens? I have been reading up about the LOCK statement, but not sure if I should need to use that.
Can someone explain what will actually happen, and how I can assure it will wait?