0

I'm trying to use LogParser 2.2 to try to convert a .csv into a SQL table, dynamically creating the columns after stripping out non alphanumeric characters. When I use the following line from the command prompt, I get an error:

logparser "SELECT.RemoveNonAlphaNumCharacters * INTO SQLCounters FROM 'C:\Users\Test\Desktop\SQL_Log_0.csv" -i:CSV -o:SQL -Server:MJNHNX4 -database:PerfMonCounters -driver:"SQL Server" -createtable:ON

The error I see is

Error: Syntax Error: (from-clause): expecting FROM keyword instead of token '*'

What's wrong with my conmmand? RemoveNonAlphaNumCharacters is a valid function in the PerfMonCounters database.

Sean Long
  • 2,163
  • 9
  • 30
  • 49

3 Answers3

0

The SQL query you give to LogParser is executed within LogParser's internal "SQL" engine and is ran against the input file (your CSV file), not against the output database. The output database is merely written to with the results of this query.

Gabriele Giuseppini
  • 1,541
  • 11
  • 19
0

You can put RemoveNonAlphaNumCharacters there, that query will not run on your database, that query will run inside logparser, so RemoveNonAlphaNumCharacters does not exist there. You must run the function later (you can pass by parameter a stored procedure to be run after import to database), or remove those characters using logparser functions.

Fernando Torres
  • 1,070
  • 8
  • 19
0

I can't find any reference to 'RemoveNonAlphaNumCharacters' in the LogParser's "SQL-Like Engine". Reading the accompanying documentation that comes with LogParser 2.2 the SQL language used by LogParser is "using a dialect of the SQL language that includes common SQL clauses". It's not exactly SQL. When I look specifically at the SELECT statement there is no mention of the method you're using.

As Fernando suggests, you need to remove those characters using LogParser's built in functions like 'REPLACE_STR' since the SQL is executed within LogParser by it's own engine.

Good luck.

John Yost
  • 693
  • 5
  • 20