in reply to Using Perl script to scan SQL 2005 error log

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)?
  • Comment on Re: Using Perl script to scan SQL 2005 error log

Replies are listed 'Best First'.
Re^2: Using Perl script to scan SQL 2005 error log
by jc7 (Initiate) on May 31, 2007 at 17:00 UTC
    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.