Query for searching system log in SSMS

중석 김 1 Reputation point
2021-11-02T01:53:56.487+00:00

Hi All,
As title, is there any way to query SQL system log not seeing it in log viewer?
The reason why I ask is I'd like to query the SQL system logs in SSMS including where clause or filters.

Thank you in advance.

SQL Server | Other
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. YufeiShao-msft 7,156 Reputation points
    2021-11-02T02:19:13.447+00:00

    Hi @중석 김 ,

    from the official doucment, the description of the system log is a record of the events logged by the Windows operating system components.
    https://learn.microsoft.com/en-us/sql/tools/configuration-manager/viewing-the-windows-application-log?view=sql-server-ver15

    but you also want to including where clause or filters. The where clause is not included in the system log.

    if you just want to query system log, you can just get from the log viewer.

    if you want to see query history in ssms, you can refer to this issue:https://stackoverflow.com/questions/5299669/how-to-see-query-history-in-sql-server-management-studio
    There is no way to see queries executed in SSMS by default

    -------------

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Erland Sommarskog 131.2K Reputation points MVP Volunteer Moderator
    2021-11-02T22:40:12.903+00:00

    Unfortunately, there is no DMV to access the errorlog.

    But you can run:

    INSERT #tmp(...)
       EXEC xp_readerrorlog
    

    And then run filtering in the temp table.

    0 comments No comments

  3. Tom Phillips 17,781 Reputation points
    2021-11-16T13:08:01.627+00:00

    The SQL Server error log is simply a text file on the hard drive. It is much simpler to just open the file using a text application.

    https://learn.microsoft.com/en-us/sql/tools/configuration-manager/viewing-the-sql-server-error-log?view=sql-server-ver15

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.