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
 General SQL Server Forums
 New to SQL Server Administration
 Question :- SELECT * FROM....

Author  Topic 

Bill_C
Constraint Violating Yak Guru

299 Posts

Posted - 2012-03-07 : 00:28:06
I would like to be able to find out the following:-

1. Is there a way I can find out what queries run against the databases use 'SELECT * FROM' (including ad-hoc queries).

2. If so, is there also a way of identifying who runs them?

Please could anyone help or give pointers in the right direction for me to find out myself.

Thanks.

Bill_C
Constraint Violating Yak Guru

299 Posts

Posted - 2012-03-07 : 06:39:45
Update:-

OK, If I use --

sys.dm_exec_cached_plans.plan_handle
sys.dm_exec_query_stats.sql_handle
sys.dm_exec_query_stats.query_plan_hash

Is there a way of linking one of these back to a user id to identify who run what?



Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2012-03-07 : 08:37:03
No, because those are just the aggregated stats of what query took what resources and a view in the the plan cache and the plans are ideally reused many times.

On SQL 2008 look at SQLAudit or extended events, on other versions look at SQL Profiler/Server-side trace.

--
Gail Shaw
SQL Server MVP
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2012-03-07 : 08:43:44
SQL Audit is Enterprise Edition only btw.
Go to Top of Page

Bill_C
Constraint Violating Yak Guru

299 Posts

Posted - 2012-03-07 : 08:48:16
Thanks, will check out SQLAUDIT
Go to Top of Page
   

- Advertisement -