Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-08-14 : 08:37:33
|
| Jim writes "I have two ftp logs one Linux, one ServU to get into one database. I can get them in just fine...and usecount () to get hitcounts on my files...problem isthat in loading the two log files I have two recordswith "date" "filename" and "hitcount" that are identical.Unfortunately the text format of the two logs areextremely different..so merging the two logs before importing them is a nightmareisn't there some way to go thru the database...look forwhere "date" "filename" match and then sum the "hitcount"field......delete the two records and create one withthe true count?thanks in advance..." |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-08-14 : 09:36:07
|
| 1. Create 3 tables:CREATE TABLE LinuxLog (FileDate datetime, FileName varchar(128), Hits int)CREATE TABLE ServULog (FileDate datetime, FileName varchar(128), Hits int)CREATE TABLE AllLogs (FileDate datetime, FileName varchar(128), Hits int)2. Import the Linux and ServU log files into their respective tables. Change the table structures to match the log file formats as necessary, as long as the three columns they share are present in both.3. INSERT the combined data into the AllLogs table like so:INSERT INTO AllLogs (FileDate, FileName, Hits)SELECT A.FileDate, A.FileName, Sum(A.Hits) AS HitsFROM (SELECT FileDate, FileName, Hits FROM LinuxLogUNION ALLSELECT FileDate, FileName, Hits FROM ServULog) AS AGROUP BY A.FileDate, A.FileName |
 |
|
|
|
|
|
|
|