SQLTeam.com | Weblogs | Forums

Show the Start Time of Current Command (not batch)


#1

I know we can get the start time of the batch via DMVs. I am looking to find the start time of the current command in a batch via DMV or some system table. This information can be seen via the Profiler, but I do not know how to get this via T-SQL.


#2

see: SQL Server Extended Events

Basically, you need to set up an event, run your batch then extract the event info.

Note that Profiler uses traces [Traces][2]

but Events are lighter weight and designed to replace traces.
[2]: https://technet.microsoft.com/en-us/library/ms191006(v=sql.105).aspx


#3

return date in the command
execute the command using XP_cmdshell
This will give you the command output


#4

I believe the two dmvs in the following article will do it for you.
http://www.mssqltips.com/sqlservertip/1338/finding-a-sql-server-process-percentage-complete-with-dmvs/