Home All Groups Group Topic Archive Search About

Viewing Query History in Management Studio

Author
26 Dec 2006 12:59 PM
Prasanna
Hi All:
   Is it possible to view the query history in SQL Server Management Studio
- I mean the list of queries that were executed from the management Studio,
the start time, end time etc?

Thanks in Advance,
Prasanna R

Author
26 Dec 2006 3:04 PM
Erland Sommarskog
Prasanna (Prasa***@discussions.microsoft.com) writes:
>    Is it possible to view the query history in SQL Server Management
> Studio
> - I mean the list of queries that were executed from the management
> Studio, the start time, end time etc?

There is no such feature.

But if you are foreseeing you can set up a trace in Profiler, or
server-side.

It's also possible to find statements in the query cache, but 1) they
may not be there 2) you can relate to whom originally submitted it.


--
Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Author
26 Dec 2006 3:39 PM
Aaron Bertrand [SQL Server MVP]
SQL Server doesn't really track this information.  You would have to use
Profiler or a custom tracing mechanism to audit all of the queries.

There are some built-in reports in Management Studio that will show you top
10 queries by cpu, i/o etc., and you can also write your own against the new
DMVs (which provide much more real-time information than sp_who/sp_who2
etc).  See the following for some ideas:

http://sqlserver2005.databases.aspfaq.com/how-do-i-mimic-sp-who2.html
http://sqlserver2005.databases.aspfaq.com/better-sp-who2.html

And once you have SP2 you can create custom reports in Management Studio;
see

http://sqlblog.com/blogs/aaron_bertrand/archive/2006/12/19/448.aspx




Show quote
"Prasanna" <Prasa***@discussions.microsoft.com> wrote in message
news:CC86CEEF-6743-492B-9A0C-6F562F6C76DA@microsoft.com...
> Hi All:
>   Is it possible to view the query history in SQL Server Management Studio
> - I mean the list of queries that were executed from the management
> Studio,
> the start time, end time etc?
>
> Thanks in Advance,
> Prasanna R

AddThis Social Bookmark Button