8

我已经开始使用 Microsoft LogParser 来分析 IIS 日志。

LogParser 允许使用来自文件的 SQL 查询并直接在命令行中为查询提供参数,例如:

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

query.sql是带有 SQL 查询的文件名

date=2010-12-29是提供给 SQL 查询的参数

这是query.sql的内容:

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

问题是我不知道如何调用文件中的参数。有人知道吗?

4

1 回答 1

9

您可以像这样使用查询文件中的参数

%VARIABLE_NAME%

所以,在你的例子中

select cs-uri-stem
      ,count(*)
from logs.log 
where date = %date%
group by cs-uri-stem 
于 2011-03-07T03:26:30.893 回答