I started a job from SSMS on my laptop using Right Click > Start Job at Step… When I was ready to be done for the day the job was still running so I selected Close thinking it was operating on the server and would continue on the server.
Today I couldn't find the job for that run so I'm second guessing how that popup operates (screen shot of popup in question below).
What happens when the Close button is clicked? If the job is terminated how exactly is it terminated (e.g. something trappable; the job in question is an Operation System type running under a proxy account).
Best Answer
The "close" button simply closes the dialog; it does not stop the running job.
You can use the following stored procedure to see the current runtime state of a given job:
To prove the "close" button does not actually stop a running job, I've created a test job:
The job takes 15 seconds to complete, by virtue of the
WAITFOR DELAY
statement. It does nothing else.Open a new query window, and add the following T-SQL to it:
Run the job via the SSMS user interface, and immediately hit the "Close" button.
Run the job activity query in step 1 by hitting the F5 key or clicking the "Execute" button.
The status of the job will be shown, something like:
In the above output, the
stop_execution_date
column is NULL, indicating the job is still running. If you wait 15 seconds for the job to complete, and re-run step 1, you'll see the output is changed to reflect the status of the job, as in:The
dbo.sp_help_jobactivity
stored procedure references thedbo.sysjobactivity
table. Microsoft docs for that table shows they use the following construct to determine the current status of a job: