Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Who did what?


Who did what?

Author
Message
TaoCanis
TaoCanis
SSC-Enthusiastic
SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)

Group: General Forum Members
Points: 148 Visits: 727
Hi,

Is this script for 2005 only or does it work for 2000? Thanks.
CJensen-489142
CJensen-489142
Grasshopper
Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)

Group: General Forum Members
Points: 12 Visits: 129
Looks like good info to have. . ., but my SSMS query keeps rejecting the code. It complains about the three inline queries for the elements from dm_exec_sql_text function, doesn't like the '.' within the function argument. Is this a database compatibility issue?

Any ideas?Smile
keliu
keliu
Forum Newbie
Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: General Forum Members
Points: 9 Visits: 276
I like to know when who is doing in the query.

Can anybody help?

Thanks.

Ke



Chadwick-788357
Chadwick-788357
SSC-Enthusiastic
SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)

Group: General Forum Members
Points: 136 Visits: 170
Very helpful script. Thanks. I changed it a bit to make the code cleaner. This produces the same result:

USE MASTER
SELECT
   s.session_id, s.host_name, s.program_name, s.client_interface_name, s.login_name
   ,s.nt_domain, s.nt_user_name, c.client_net_address, c.local_net_address
   --,c.connection_id,c.parent_connection_id, c.most_recent_sql_handle
   ,(SELECT text FROM sys.dm_exec_sql_text(c.most_recent_sql_handle)) as sqlscript
   ,(SELECT db_name(dbid) FROM sys.dm_exec_sql_text(c.most_recent_sql_handle)) as databasename
   ,(SELECT object_id(objectid) FROM sys.dm_exec_sql_text(c.most_recent_sql_handle)) as objectname
FROM
   sys.dm_exec_sessions as s
INNER JOIN
   sys.dm_exec_connections as c
   ON c.session_id = s.session_id
logicinside22
logicinside22
Old Hand
Old Hand (328 reputation)Old Hand (328 reputation)Old Hand (328 reputation)Old Hand (328 reputation)Old Hand (328 reputation)Old Hand (328 reputation)Old Hand (328 reputation)Old Hand (328 reputation)

Group: General Forum Members
Points: 328 Visits: 1387
nice script ...amazing result which i want to see it.
thanks

Aim to inspire rather than to teach.
SQL Server DBA
SQLRNNR
SQLRNNR
SSC-Insane
SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)

Group: General Forum Members
Points: 21017 Visits: 18258
Nice script indeed.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw

SQLRNNR
SQLRNNR
SSC-Insane
SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)

Group: General Forum Members
Points: 21017 Visits: 18258
Here's another twist on the same script


USE MASTER
Go
SELECT cr.DatabaseName
   ,s.session_id, s.host_name, s.program_name, s.client_interface_name, s.login_name
   ,s.nt_domain, s.nt_user_name, c.client_net_address, c.local_net_address
   ,cr.ObjName
   ,cr.Query
FROM sys.dm_exec_sessions as s
INNER JOIN sys.dm_exec_connections as c
   ON c.session_id = s.session_id
CROSS APPLY (SELECT db_name(dbid) AS DatabaseName,object_id(objectid) AS ObjName,ISNULL((SELECT text AS [processing-instruction(definition)]
         FROM sys.dm_exec_sql_text(c.most_recent_sql_handle)
         FOR XML PATH(''), TYPE
      Wink,'') as Query
            FROM sys.dm_exec_sql_text(c.most_recent_sql_handle)) cr
ORDER BY c.session_id





Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw

logicinside22
logicinside22
Old Hand
Old Hand (328 reputation)Old Hand (328 reputation)Old Hand (328 reputation)Old Hand (328 reputation)Old Hand (328 reputation)Old Hand (328 reputation)Old Hand (328 reputation)Old Hand (328 reputation)

Group: General Forum Members
Points: 328 Visits: 1387
HI SQL RNNR

I was testing your script so just want to make sure little thing in result set session_id is the SPID right?
is there possibility with this script can show up the date and time of user . like what time they ran any query?
Thanks

Aim to inspire rather than to teach.
SQL Server DBA
SQLRNNR
SQLRNNR
SSC-Insane
SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)

Group: General Forum Members
Points: 21017 Visits: 18258
These scripts are for for current activity.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw

Iwas Bornready
Iwas Bornready
SSCrazy Eights
SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)

Group: General Forum Members
Points: 8590 Visits: 885
The problem I just had with it is that I do not have permissions to run this on production.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search