I'm having problems exporting the log to a SQL database. The errors I seem to get are related to the field name/data type. I ran the following below to get the field names.
LogParser "select * INTO C:\log.txt From 'C:\Program Files\Microsoft
SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG'" -i:TSV -o:TSV -headerrow:off
This is what it returns:
Filename RowNumber Field1
C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG 1 2008-05-11 22:58:21.48 Server Microsoft SQL Server 2005 - 9.00.1399.06 (Intel X86)
C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG 2 Oct 14 2005 00:33:37
C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG 3 Copyright (c) 1988-2005 Microsoft Corporation
It appears that the only fields are filename, rownumber, and field1. How do I address the date field, source, and message field?
I can output to a text file with no problem, but with into SQL server I keep getting errors. If I use the iHeaderFile parameter, what do I put in the text file? This is what I have so far.
LogParser "select STRCAT(STRCAT(DATE,' '), TIME) as LogDateTime, SOURCE, Message INTO SQLEvents2 From 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG'" -i:TSV -iseparator:spaces -iHeaderFile:c:\scripts\sqleventsformatfile.txt -headerRow:OFF -nskiplines:9 -o:SQL -server:xxxx -database:Events -driver:"SQL Server" -username:xxxx -password:xxxx -createTable:ON