jc7 has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's minimum standard of quality and will not be displayed.
  • Comment on Using Perl script to scan SQL 2005 error log

Replies are listed 'Best First'.
Re: Using Perl script to scan SQL 2005 error log
by terce (Friar) on May 30, 2007 at 20:43 UTC

    It will be difficult to diagnose your problem if you don't give an example of the error message or some other indication of how your script fails with SQL 2005

Re: Using Perl script to scan SQL 2005 error log
by jZed (Prior) on May 30, 2007 at 20:58 UTC
    In addition to doing as terce says and letting us see an example of what fails and how, it would help to know something about how your script works - does it use modules (which)?
      Thank you both for helping me. Here is an example and the outcomes. Please let me know if you need any further info. Thank you again!

      Perl Script:

      sub scanSQLErrorlog {
      ……
      # now open the errorlog file for scan
      unless (open(LOG, "$sqlErrorlog")) {
      $ref->{log_open_error} = "***Error: could not open $sqlErrorlog for read. ";
      $ref->{log_open_error} .= Win32::FormatMessage(Win32::GetLastError);
      return $ref;
      }
      # get the very first errorlog line. It has the version info.
      $_ = <LOG>;
      if (/^\s*(\d\/\-+\s+\d\:\.+)\s+(?:kernel|Server|spid\d+)\s+(Microsoft\s+SQL\s+Server.+)/i) {
      ($ref->{first_recorded_date}, $ref->{sql_version}) = ($1, $2);
      }
      ……
      }

      The first line of SQL server 2000 error log is like:
      2007-05-30 08:29:03.17 server Microsoft SQL Server 2000 - 8.00.2040 (Intel X86)
      After running the script,
      $ref->{first_recorded_date} has “2007-05-30 08:29:03.17”
      $ref->{sql_version} has “Microsoft SQL Server 2000 - 8.00.2040 (Intel X86)”

      The first line of SQL server 2005 error log is like:
      2007-05-30 15:49:21.56 Server Microsoft SQL Server 2005 - 9.00.3054.00 (Intel X86)
      After running the script,
      $ref->{first_recorded_date} has nothing.
      $ref->{sql_version} has nothing.
      It does not grip anything from the log of SQL 2005. There is no error message.