You are correct! It should be /^\s*([\d\/\-]+\s+[\d\:\.]+) ... It was a result of not using <code> around the script. Sorry for the confusion. Thank you very much for your helping!

I did check the value of $ref->{log_open_error}. It is blank. And $sqlErrorLog does point to correct path and file name. Please see the sample below. From the output, we see it grabbed the first link of log for SQL 2000 error. For SQL 2005, however, it showed 'yp2'.

Sample script:

... # now open the errorlog file for scan unless (open(LOG, "$sqlErrorlog")) { $ref->{log_open_error} = "***Error: could not open $sqlErrorlo +g for read. "; $ref->{log_open_error} .= Win32::FormatMessage(Win32::GetLastE +rror); return $ref; } print "Error: $ref->{log_open_error}\n"; print "$sqlErrorlog\n"; # get the very first errorlog line. It has the version info. $_ = <LOG>; print "$_\n"; if (/^\s*([\d\/\-]+\s+[\d\:\.]+)\s+(?:kernel|Server|spid\d+)\s+(Micros +oft\s+SQL\s+Server.+)/i) { ($ref->{first_recorded_date}, $ref->{sql_version}) = ($1, $2 +); print " DT: $ref->{first_recorded_date}\n"; print " Version: $2\n"; }
The output is:
Error:
\\SQL2000Server\d$\MSSQL\LOG\ErrorLog
2007-05-30 08:29:03.17 server Microsoft SQL Server 2000 - 8.00.2040 (Intel X86)
DT: 2007-05-30 08:29:03.17
Version: Microsoft SQL Server 2000 - 8.00.2040 (Intel X86)
...
Error:
\\SQL2005Server\d$\MSSQL\LOG\ERRORLOG
ÿþ2


In reply to Re^2: How to open SQL 2005 errorlog? by Anonymous Monk
in thread 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.