views:

37

answers:

3

I want to be able to see all the queries that has been executed on the server last 2 days etc.

see the script, date of execution, sender etc. is there any way?

I am using SQL X 2005.

+2  A: 

I don't believe it's possible without SQL Server Profiler running.

Mike C.
Correct. SQL Server does not log queries.
Donnie
It does if SQL Trace is enabled and setup with right events to track: http://msdn.microsoft.com/en-us/library/ms191511.aspx
DenNukem
+1  A: 

Here is a free, open-source Profiler tool that might help.

Profiler for Microsoft SQL Server 2005/2008 Express Edition

DOK
+1  A: 

Yes you can use SQL-Trace to log each command submitted to the server. It's the same mechanism used by the profiler, but you do not have to have the profiler or any other tool to use it.

There are two modes in which SQL Trace can run - in-memory buffer and disk file. The former is only used by profiler, is not documented and should not be used. Use the disk-file mode. The file can later on be opened on the same or different machine and even loaded into a table for analysis.

To learn more go to this page: http://msdn.microsoft.com/en-us/library/ms191511.aspx and search for section titled "To perform monitoring tasks with SQL Trace by using Transact-SQL stored procedures"

DenNukem
Sounds charming, will this work in Express edition?
Shimmy
I'm 95% certain it does. Certainly worth a try.
DenNukem