locked
can't see myself running! RRS feed

  • Question

  • Something odd, when I put some code like the following into an SP and run the SP, it captures the request and task that shows itself running, and all is good.

    But when I run the same code directly in the query analyzer, it doesn't show itself as a request or task.  That seems bad.

    You can see there is nothing in it to exclude itself, any idea why it doesn't appear as a request or task?

    select
     r.session_id, r.[status], 
     ta.task_address, ta.task_state, 
     r.command, r.wait_type
    from sys.dm_exec_requests r
    		left join sys.dm_os_tasks ta
    			on r.session_id = ta.session_id

    Thanks.

    Josh

    ps - SQL 2005 32-bit sp2

     

    Friday, April 30, 2010 9:48 PM

Answers

  • Aha.  Well, now I'm at home, and on this copy of SQL 2008 Express 32-bit, I *can* see myself running!

    Olaf, what version did you run on?

    Thanks.

    Josh

    select @@spid as myspid
    
    select
     r.session_id, r.[status], 
     ta.task_address, ta.task_state, 
     r.command, r.wait_type
    from sys.dm_exec_requests r
    		left join sys.dm_os_tasks ta
    			on r.session_id = ta.session_id
    where r.session_id > 50
    order by r.session_id desc
    • Proposed as answer by Tom Li - MSFT Monday, May 3, 2010 5:54 AM
    • Marked as answer by Tom Li - MSFT Thursday, May 6, 2010 11:08 AM
    Saturday, May 1, 2010 4:34 AM

All replies

  • Hello Josh,

    I can't agree to this; if I add the filter

    WHERE r.session_id = @@SPID

    then I can see my session with the request.


    Olaf Helper ----------- * cogito ergo sum * errare humanum est * quote erat demonstrandum * Wenn ich denke, ist das ein Fehler und das beweise ich täglich http://olafhelper.over-blog.de
    • Proposed as answer by Tom Li - MSFT Monday, May 3, 2010 5:54 AM
    Saturday, May 1, 2010 4:15 AM
  • Aha.  Well, now I'm at home, and on this copy of SQL 2008 Express 32-bit, I *can* see myself running!

    Olaf, what version did you run on?

    Thanks.

    Josh

    select @@spid as myspid
    
    select
     r.session_id, r.[status], 
     ta.task_address, ta.task_state, 
     r.command, r.wait_type
    from sys.dm_exec_requests r
    		left join sys.dm_os_tasks ta
    			on r.session_id = ta.session_id
    where r.session_id > 50
    order by r.session_id desc
    • Proposed as answer by Tom Li - MSFT Monday, May 3, 2010 5:54 AM
    • Marked as answer by Tom Li - MSFT Thursday, May 6, 2010 11:08 AM
    Saturday, May 1, 2010 4:34 AM
  • Hello Josh,

    Can you "see yourself" running and the problem is solved or can't you? I don't get it out clearly from your last post, because you wrote
    ... I *can* see ... ?

    Actually I am running Microsoft SQL Server 2008 R2 (CTP) - 10.50.1352.12; the last CTP and not RTM, so may it's not representative.


    Olaf Helper ----------- * cogito ergo sum * errare humanum est * quote erat demonstrandum * Wenn ich denke, ist das ein Fehler und das beweise ich täglich http://olafhelper.over-blog.de
    Saturday, May 1, 2010 4:49 AM
  • Olaf,

    My problem at work with the old SQL 2005 remains, but it's not a problem so much as a question. 

    It isn't doing any harm, I just wanted to understand it.  Once wrapped in an SP it seemed to behave even there.

    Thanks.

    Josh

    Saturday, May 1, 2010 2:42 PM