Announcement

Collapse
No announcement yet.

SQL Script to export logs

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • SQL Script to export logs

    Too tired to for this one.

    I need to, for one SQL 2005 server running on 2003R2x64 , export and clear the agent error log and the SQL error log (export should be to CSV to a UNC path-can be to a mapped drive letter)

    The recycling is easy -- I use:
    Code:
    EXECsp_cycle_errorlog;
    EXEC msdb.dbo.sp_cycle_agent_errorlog;
    
    But I cannot find anything for the export
    Tom Jones
    MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
    PhD, MSc, FIAP, MIITT
    IT Trainer / Consultant
    Ossian Ltd
    Scotland

    ** Remember to give credit where credit is due and leave reputation points where appropriate **

  • #2
    Re: SQL Script to export logs

    The logs are nothing special. they're actually just txt files on the drive in the Log folder under the sql install dir.
    So you may be able to do something with them the same way you do with the NT logs with a log reader of some kind... like LogParser.

    I've never tried it with sql logs before, but that's how I'd tackle this... then I'd probably wrap the whole thing up in a powershell script.
    Sean McCown, SQL Server MVP

    See my FREE SQL Server training videos at:
    http://www.MidnightDBA.com

    Blog Author of:
    Database Underground -- http://infoworld.com/blogs/sean-mccown
    DBA Rant http://dbarant.blogspot.com

    Comment


    • #3
      Re: SQL Script to export logs

      Sounds reasonable
      I assumed they were in a db table somewhere

      OK, no problem powershelling it then!
      Tom Jones
      MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
      PhD, MSc, FIAP, MIITT
      IT Trainer / Consultant
      Ossian Ltd
      Scotland

      ** Remember to give credit where credit is due and leave reputation points where appropriate **

      Comment


      • #4
        Re: SQL Script to export logs

        Y if they were in a table that would make it so much easier really.
        You know, you could also SSIS it if you wanted to.
        Sean McCown, SQL Server MVP

        See my FREE SQL Server training videos at:
        http://www.MidnightDBA.com

        Blog Author of:
        Database Underground -- http://infoworld.com/blogs/sean-mccown
        DBA Rant http://dbarant.blogspot.com

        Comment


        • #5
          Re: SQL Script to export logs

          My experience of SSIS is fairly limited, but PS to copy the files seems easy
          Then again, might be a good learning experience....

          Many thanks
          Tom Jones
          MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
          PhD, MSc, FIAP, MIITT
          IT Trainer / Consultant
          Ossian Ltd
          Scotland

          ** Remember to give credit where credit is due and leave reputation points where appropriate **

          Comment

          Working...
          X