July 24, 2009 at 2:35 pm
I am creating a stored procedure to identify, and kill a long running Business Objects query in the SQL Server database. I am able to identify the BO SQL iin the database with the BO user id, and also able to check the status "RUNNABLE" in sys_processes table, but last_batch column keeps updating timestamp for EACH REQUEST sent to the DB for the same BO query. Hence, I am unable to identify the start time, and to find out how long the BO SQL has been running. Does anyone know, how can I accomplish this ?
July 25, 2009 at 1:38 am
What version of SQL Server are running?
July 25, 2009 at 1:43 am
Check this article. See if this helps.
July 27, 2009 at 6:54 am
For 2005/2008, take a look at sys.dm_exec_syessions. It will give you a basic breakdown of information for the connections in the system, including start times on the last batch. For more detailed information, take a look at sys.dm_exec_requests. That will give you very specific information about what a process is waiting for, what it's doing, what statement it's on within the batch, etc. In some cases, not all, not even most, it will also show a percent complete, but don't rely on that value in any way. It may or may not be accurate and useful.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
July 27, 2009 at 7:50 am
SQL 2005
July 27, 2009 at 7:54 am
This SP gets the start time of the running SQL from system table dm_exec_* and system function dm_exec_sql.
My understanding is ->One SQL sends multiple requests to the db, the start time in dm_* tables all point to the start time of EACH REQUEST, thus at a given point of time, I am unable to determine when the SQL started.
July 27, 2009 at 7:55 am
My understanding is ->One SQL sends multiple requests to the db, the start time in dm_exec_* tables all point to the start time of EACH REQUEST, thus at a given point of time, I am unable to determine when the SQL started.
July 27, 2009 at 8:25 am
When you say SQL, do you mean an individual SQL statement? One that is currently running? I'm not entirely sure, but you may not be able to drill down to that level without capturing statements in a trace. That's one way of doing it, but you would already have to have the trace in place. You couldn't turn it on in a moment's notice.
I'll have to test the DMV to see if it records a statement or a batch start time.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
July 27, 2009 at 9:53 am
I mean the Report SQL which is running in the db. I am trying to identify the start time of the report SQL.
July 27, 2009 at 11:08 am
I'm not trying to be obtuse, I just don't understand what you are referring to. Do you mean queries coming from Reporting Services?
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
July 28, 2009 at 3:15 am
Do you mean to say that report sql is being repeatedly executed (maybe from diff connections) and you want to find out when this whole thing started ?
"Keep Trying"
July 28, 2009 at 9:27 am
I just validated it, you can get the start time for a statement within a batch by querying sys.dm_exec_sessions. I posted a blog entry on it here[/url].
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
Viewing 12 posts - 1 through 11 (of 11 total)
You must be logged in to reply to this topic. Login to reply