SQL Clone
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 (176 reputation)SSC-Enthusiastic (176 reputation)SSC-Enthusiastic (176 reputation)SSC-Enthusiastic (176 reputation)SSC-Enthusiastic (176 reputation)SSC-Enthusiastic (176 reputation)SSC-Enthusiastic (176 reputation)SSC-Enthusiastic (176 reputation)

Group: General Forum Members
Points: 176 Visits: 751
Hi,

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

Group: General Forum Members
Points: 14 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
Grasshopper
Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)

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

Can anybody help?

Thanks.

Ke



Chadwick-788357
Chadwick-788357
SSC Veteran
SSC Veteran (240 reputation)SSC Veteran (240 reputation)SSC Veteran (240 reputation)SSC Veteran (240 reputation)SSC Veteran (240 reputation)SSC Veteran (240 reputation)SSC Veteran (240 reputation)SSC Veteran (240 reputation)

Group: General Forum Members
Points: 240 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
Hall of Fame
Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)

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

Aim to inspire rather than to teach.
SQL Server DBA
SQLRNNR
SQLRNNR
SSC Guru
SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)

Group: General Forum Members
Points: 100140 Visits: 18616
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 Guru
SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)

Group: General Forum Members
Points: 100140 Visits: 18616
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
),'') 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
Hall of Fame
Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)

Group: General Forum Members
Points: 3673 Visits: 1449
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 Guru
SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)

Group: General Forum Members
Points: 100140 Visits: 18616
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
One Orange Chip
One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)

Group: General Forum Members
Points: 29520 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