BULK INSERT command may take a long time to run.
I have a program that receives multiple files and pushes them to the DB using the
BULK INSERT command to a specific table.
After a file is uploaded, the program deletes it and moves to the next.
BULK INSERT command may continue to run on the DB after the program stopped. so a file may be loaded to the DB, or still in process when my program starts.
So, my questions are:
- Can I tell if a
BULK INSERTcommand is still running for a specific table?
- Can I tell if a file has been already loaded to the DB?
I can get the running query by running:
select t.text from sys.dm_exec_requests r cross_apply sys.dm_exec_sql_text(r.sql_handle) t where command= 'BULK INSERT'
but how can I know on which table it runs?