Microsoft LogParser: How to use parameters in a file
Asked Answered
A

1

8

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?

Afterheat answered 30/12, 2010 at 15:32 Comment(0)
R
9

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 
Rebeca answered 7/3, 2011 at 3:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.