troubleshooting Question

Insert CSV to SQL using logparser - MUCHO Points ;)

Avatar of m0tek
m0tek asked on
DatabasesMicrosoft SQL Server 2005
3 Comments1 Solution1277 ViewsLast Modified:
Hi!
im trying to use logparser in order to insert a csv file to sql
the csv fields are

TimeStamp      Aggregated Event Count      Name      File Name      File Path      Destination Address      Destination Asset Resource      Destination Host Name      Destination Zone Resource      Device Host Name      Device Zone Resource      Device Custom String5      Device Custom String6

the SQL Fields are

USE [Metrics]
GO
/****** Object:  Table [dbo].[Arc_AV]    Script Date: 12/21/2009 18:28:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Arc_AV](
      [EventID] [int] IDENTITY(1,1) NOT NULL,
      [TimeStamp] [varchar](50) NULL,
      [CountArc] [smallint] NULL,
      [Name] [varchar](50) NULL,
      [FileName] [varchar](300) NULL,
      [FilePath] [varchar](300) NULL,
      [DestIP] [varchar](50) NULL,
      [DestResource] [varchar](50) NULL,
      [DestHost] [varchar](50) NULL,
      [DestZone] [varchar](50) NULL,
      [DeviceHostName] [varchar](50) NULL,
      [DeviceZone] [varchar](50) NULL,
      [Action_1] [varchar](50) NULL,
      [Action_2] [varchar](50) NULL,
 CONSTRAINT [PK_Arc_AV] PRIMARY KEY CLUSTERED
(
      [EventID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF

EventID should be an index (auto) identification

i cant parse the CSV to the db - is there a way to tell logparser which field goes into what?

this is what im getting

C:\Program Files\Log Parser 2.2>LogParser "SELECT [TimeStamp] AS TimeStamp, [Agg
regated Event Count] AS CountArc, [Name] AS Name INTO dbo.Arc_AV FROM g:\av.csv"
 -i:CSV -o:SQL -server:M0TEK-PC\METRICS -database:Metrics -driver:"SQL Server" -
username:dummy -password:********* -createTable:OFF
Task aborted.
SQL table column "EventID_DB" data type is not compatible with SELECT clause
  item "TimeStamp" (type STRING)

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros