Home > Management Studio, SQL Agent, SQLServer, SQLServer 2005, SQLServer 2008, SQLServer 2008 R2, SQLServer 2012 > SQL Server – Reading ERRORLOG with xp_ReadErrorLog
  1. Bala Krishna
    January 25, 2013 at 9:41 pm

    Hi Vishal,

    This is really amazing stuff from you.

    Thanks for posting.

  2. Dhiva
    June 18, 2013 at 7:15 pm

    fantastic one

  3. Jason
    October 29, 2014 at 12:43 am

    What is the default for the SortOrder?

  4. $ubha
    April 14, 2015 at 11:52 pm

    I tried using the startdate and enddate parameters, but no luck,
    am i missing anything :

    exec sys.xp_readerrorlog 2,2,NULL,NULL,’20150414′,null

    • December 6, 2015 at 2:59 am

      $ubha try exec sys.xp_readerrorlog 2,2,”,”,’20150414′,null
      The text parameters are expecting text values and does not accept null

  5. June 9, 2015 at 9:57 am

    “Error executing extended stored procedure: Invalid Parameter Type”

    • Jason
      May 18, 2016 at 8:42 pm

      Are you using single quotes for the log parameter?:
      /* BAD */
      EXEC xp_ReadErrorLog ‘0’
      — Receive: Msg 22004, Level 12, State 1, Line 19
      — Error executing extended stored procedure: Invalid Parameter Type

      /* Good */
      EXEC xp_ReadErrorLog 0

  6. rahul jain
    June 25, 2015 at 9:09 pm

    what if want to eliminate some log containing specific message ?

  7. February 2, 2016 at 2:24 pm

    Great post – thank you very much, Vishal!

  8. stekosan
    February 29, 2016 at 7:27 am

    try: sp_readerrorlog

  9. Jason
    May 18, 2016 at 8:48 pm

    Two comments:

    Are you using single quotes for the log parameter?:
    /* BAD */
    EXEC xp_ReadErrorLog ‘0’
    — Receive: Msg 22004, Level 12, State 1, Line 19
    — Error executing extended stored procedure: Invalid Parameter Type

    /* Good */
    EXEC xp_ReadErrorLog 0

    Watch out for those ticks `, you’ll need single quotes ‘
    /* BAD */
    exec sys.xp_readerrorlog 2,2,NULL,NULL,`20150414`,null
    — Receive: Msg 102, Level 15, State 1, Line 22 Incorrect syntax near ‘`’.

    /* Good */
    exec sys.xp_readerrorlog 2,2,NULL,NULL,’20150414′,null
    –Receive most recent text from SQL Agent Log

  10. July 26, 2016 at 9:04 pm

    FYI, you should qualify any string parameters with NVARCHAR notation:

    xp_readerrorlog 0, 1, N’SearchString’, NULL, NULL, NULL, NULL, N’Desc’

  11. back
    August 8, 2016 at 1:09 pm

    thank you it is very helpful to me

  1. February 8, 2013 at 12:42 pm
  2. February 8, 2013 at 12:46 pm
  3. May 1, 2013 at 10:48 am
  4. May 3, 2013 at 2:03 am
  5. August 21, 2013 at 4:06 am
  6. March 16, 2017 at 9:21 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: