Hi Monks! I need your wisdom! I am trying to scan SQL 2005 error log using a Perl script. It works with both SQL 7.0 and SQL 2000, but not for SQL 2005. It appears that it is unable to open the SQL 2005 error log correctly. Please help and let me know if you need any more info. Thank you very much in advance for any of your advice!

sub scanSQLErrorlog { …… # now open the errorlog file for scan: unless (open(LOG, "$sqlErrorlog")) { $ref->{log_open_error} = "***Error: could not open $sqlErrorlog for re +ad. "; $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 (I +ntel 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.305 +4.00 (Intel X86)

After running the script,
$ref->{first_recorded_date} has nothing.
$ref->{sql_version} has nothing.
It does not grab anything from the log of SQL 2005. There is no error message either.

Edit: g0n - code tags


In reply to How to open SQL 2005 errorlog? by jc7

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.