SQL Server SQL Query Log

Posted on 2006-04-03
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?

Question by:gregca80
    LVL 142

    Accepted Solution

    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.
    LVL 75

    Expert Comment

    by:Aneesh Retnakaran
    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
    LVL 75

    Expert Comment

    by:Aneesh Retnakaran
    Another freeware tool similar to SQL profiler is 'SQLSPY'
    LVL 13

    Expert Comment

    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.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
    Introduction In my previous article ( I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
    Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
    Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now