SQL Server Background Job Queue – How to Create a Background Job

sql servert-sql

While exploring the SQL server I came up with following views:

sys.dm_exec_background_job_queue;
sys.dm_exec_background_job_queue_stats;

Official site tells that

It Returns a row for each query processor job that is scheduled for asynchronous (background) execution.

So how can I create a background (Asynchronous) jobs what will populate these system views to see queued jobs in these tables or somewhere else?

PS: I am new to SQL Server I don't know if there is something like background job! Correct me if I am wrong.

Best Answer

You can't create one of these jobs. They aren't SQL Server Agent jobs or anything you can create manually, they're background tasks that SQL Server performs (like asynchronous updates to statistics).

You could trigger temporary population of the DMV by updating enough rows in a table and then running queries that force stats to be re-calculated, but this would be a very hunt-and-peck operation that will rely on incredibly lucky timing.