We help IT Professionals succeed at work.

SQL Server SQL Query Log

gregca80 asked
Medium Priority
Last Modified: 2008-03-03

I have several databases in SQL Server. Is there a place that SQL Server keeps a log of each SQL query it executes for a particular DB? If so, how and where can I access it?

Watch Question

Billing Engineer
Most Valuable Expert 2014
Top Expert 2009
no, there is no log kept (automatically), at least not for SELECT queries.
the others (UPDATE, INSERT, DELETE) are stored in the transaction log, where you need some 3rd party tools to get them.

you can trace all queries using the query profiler, however that is not recommended to run all the time only for tracing, it's rather used to find problem sql at short term.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
AneeshDatabase Consultant
Top Expert 2009

Hi gregca80,
the log file of each database contains the queries executed on that particular database.
if you want to view the contents of this log, you can make use of third party tools such as Lumigent Log explorer
AneeshDatabase Consultant
Top Expert 2009

Another freeware tool similar to SQL profiler is 'SQLSPY'
aneesh - the log file is continously pruned depending on several options (recoverability settings, recovery mode, transactions being completed, etc). So this option is not what he is looking for. He is looking for ALL queries ever run on that database.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.