Friday, March 9, 2012

How to import apache log file into a table in SQL 2000

Hi friends,
I need to import a web log file coming from apache server into a table.But the problem is that log file is in some strange format.Its not in a comma delimited or not a tab delimited.
I am sending u some records of that file for a refrence.

62.219.115.5 - - [01/Mar/2007:04:26:51 -0700] "GET http://zdpub.dl.llnw.net/flvplayer3.../c4/window4.jpg HTTP/1.0" 304 177 "http://zdpub.vo.llnwd.net/o2/flvplayer/frontend6.swf" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; NetCaptor 7.5.4; .NET CLR 1.1.4322; FDM; .NET CLR 2.0.50727)"

165.21.154.9 - - [01/Mar/2007:04:53:53 -0700] "GET http://zdpub.dl.llnw.net/crankygeek...geeks.052.i.mp4 HTTP/1.0" 206 100740 "-" "iTunes/7.0.2 (Macintosh; N; PPC)"

217.255.204.70 - - [01/Mar/2007:10:30:01 -0700] "GET http://zdpub.dl.llnw.net/crankygeek...kygeeks.053.mov HTTP/1.0" 200 107184139 "-" "iTunes/7.0.2 (Macintosh; N; Intel)"

194.94.44.4 - - [01/Mar/2007:10:30:43 -0700] "GET http://zdpub.dl.llnw.net/crankygeek...geeks.053.i.mp4 HTTP/1.0" 200 687979 "-" "iTunes/7.0.2 (Macintosh; N; Intel)"

85.124.149.78 - - [01/Mar/2007:10:31:51 -0700] "GET http://zdpub.dl.llnw.net/crankygeek...kygeeks.053.mov HTTP/1.0" 200 138751823 "-" "Democracy/0.9.5.2 (http://www.participatoryculture.org)"

I m so confused how to import this file to a table.
And that is something that I need to do urgently.
Any help will be greatly apreciated.
Thanks.[color=black][font=Arial]I would change this file extension to txt. [/font]

[color=black][font=Arial] [/font]

[color=black][font=Arial]In Enterprise Manager go to Tools - Data Transformation Services - Import Data and follow a wizard. Change Data Source to txt file. [/font]

[color=black][font=Arial] [/font]

[color=black][font=Arial] [/font]

[color=black][font=Arial]It should create a table as is. [/font]


Hope it helps.|||

Quote:

Originally Posted by iburyak

[color=black][font=Arial]I would change this file extension to txt. [/font]

[color=black][font=Arial] [/font]

[color=black][font=Arial]In Enterprise Manager go to Tools - Data Transformation Services - Import Data and follow a wizard. Change Data Source to txt file. [/font]

[color=black][font=Arial] [/font]

[color=black][font=Arial] [/font]

[color=black][font=Arial]It should create a table as is. [/font]


Hope it helps.


Hi,
Actually I didnt understand what you are saying.
I mean I have table ready in my database in which I need to import this file.
e.g first column in my table is I.P add. in which it takes 62.219.115.5.
Second field is browser i.d.In that field instead of taking [01/Mar/2007:04:26:51 -0700] ,it takes - and so on.
So my problem is when I try to import data using DTS its not fetching correct data in respective columns.I guess this is because of the format of the file.
Thanks|||Do you need this as one time deal or on a permanent basis like on schedule every day?

You are having a hard case it is true.

What I was trying to tell you let SQL generate a new temporary table on a server and then deal with it on a server side. It probably will create one column with all text in it for each record. But then you would be able to process it and insert into production table if possible.

I don't think server would be able to split this record into correct columns with no delimiters.|||Had you ever seen this?

http://www.microsoft.com/downloads/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&displaylang=en

It is a log parser. I used it once with pretty good success.

Good Luck.|||Actually I'll have to do this once in a month.
I'll get log files for whole month from some other server.
And at the end of the month,I'll have to parse all files in to a table.|||Try to use logparser then.

No comments:

Post a Comment