Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft LogParser: How to use parameters in a file

I have started to use Microsoft LogParser in order to analyse IIS logs.

LogParser allows using SQL query from a file and supply parameters to the query directly in a command line, for example:

LogParser file:query.sql?date=2010-12-29 -i:IISW3C

query.sql is a file name with SQL query

date=2010-12-29 is a parameter that is supplied to the SQL query

Here is content of query.sql:

select cs-uri-stem
      ,count(*)
from logs.log 
where date = <date>
group by cs-uri-stem 

The problem is that I don't know how to call parameter in the file. Does anybody know this?

like image 734
Timofey Avatar asked Dec 30 '10 15:12

Timofey


1 Answers

You can use the parameters in you query file like this

%VARIABLE_NAME%

So, in your example

select cs-uri-stem
      ,count(*)
from logs.log 
where date = %date%
group by cs-uri-stem 
like image 123
jzbruno Avatar answered Sep 29 '22 12:09

jzbruno