Logging ALL Queries on a SQL Server 2008 Express Database?

SQL Server Profiler:

  • File → New Trace
  • The "General" Tab is displayed.
  • Here you can choose "Save to file:" so its logged to a file.
  • View the "Event Selection" Tab
  • Select the items you want to log.
  • TSQL → SQL:BatchStarting will get you sql selects
  • Stored Procedures → RPC:Completed will get you Stored Procedures.

More information from Microsoft: SQL Server 2008 Books Online - Using SQL Server Profiler

Update - SQL Express Edition:

A comment was made that MS SQL Server Profiler is not available for the express edition.
There does appear to be a free alternative: Profiler for Microsoft SQL Server 2005 Express Edition


There is one more way to get information about queries that has been executed on MS SQL Server Express described here.

Briefly, it runs smart query to system tables and gets info(text, time executed) about queries(or cached query plans if needed). Thus you can get info about executed queries without profiler in MSSQL 2008 Express edition.

SELECT deqs.last_execution_time AS [Time], dest.TEXT AS [Query]
FROM sys.dm_exec_query_stats AS deqs
CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest
ORDER BY deqs.last_execution_time DESC

…Late answer but I hope it would be useful to other readers here…

Using SQL Server Express with advanced auditing requirements such as this is not really optimal unless it’s only in development environment.

You can use traces (www.broes.nl/2011/10/profiling-on-sql-server-express/) to get the data you need but you’d have to parse these yourself.

There are third party tools that can do this but their cost will be quite high. Log explorer from ApexSQL can log everything but select and Idera’s compliance manager will log select statements as well but it’s cost is a lot higher.


You can log changes. SQL Server 2008 will make this especially easy with Change Data Capture. But SQL Server isn't very good at logging SELECTs.

It is theoretically possible with the profiler, but it will kill your performance. You might "get away with it" on your desktop, but I think you'll notice your machine acting slow enough to cause problems. And it definitely won't work after any kind of deployment.

One important point a couple others have missed already: unless they changed something for 2008 I didn't hear about, you can't trigger a SELECT.