Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 view recently ran queries

Author  Topic 

jar21

51 Posts

Posted - 2010-01-11 : 14:28:15
Is there a way to view queries that were ran directly from the sql management studio on the server itself?

Enjoy Life This Is Not A Rehearsal.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-01-11 : 14:36:58
Yes but you'd need a trace running to capture that. You can use the ApplicationName column in the trace to differentiate the queries from other applications.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

jar21

51 Posts

Posted - 2010-01-11 : 14:38:29
what about completely after the fact? they've been ran this morning and yesterdaY?

Enjoy Life This Is Not A Rehearsal.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-01-11 : 14:41:07
There's a DMV that shows what queries have been run, but I don't think it includes the ApplicationName column. I don't have the DMV in front of me at the moment.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

shan
Yak Posting Veteran

84 Posts

Posted - 2010-01-11 : 14:59:07
See if this is useful


http://searchsqlserver.techtarget.com/generic/0,295582,sid87_gci1265214,00.html#

You might change the below to serve your need.

SELECT TOP 10 SESSION_ID, LOGIN_TIME, HOST_NAME,
PROGRAM_NAME, LOGIN_NAME, NT_DOMAIN,
NT_USER_NAME, STATUS, CPU_TIME, MEMORY_USAGE,
TOTAL_SCHEDULED_TIME, TOTAL_ELAPSED_TIME,
LAST_REQUEST_START_TIME,
LAST_REQUEST_END_TIME, READS, WRITES,
LOGICAL_READS, TRANSACTION_ISOLATION_LEVEL,
LOCK_TIMEOUT, DEADLOCK_PRIORITY, ROW_COUNT,
PREV_ERROR FROM SYS.DM_EXEC_SESSIONS ORDER
BY MEMORY_USAGE DESC


-Shan
Go to Top of Page

jar21

51 Posts

Posted - 2010-01-11 : 15:43:07
Very cool on both replies thanks!
Go to Top of Page

shan
Yak Posting Veteran

84 Posts

Posted - 2010-01-11 : 15:57:06
You are welcome...


-Shan
Go to Top of Page
   

- Advertisement -