logparser TO_TIME 输出与 sql 时间数据类型不匹配

logparser TO_TIME output not matching the sql time datatype

以下是来自 logparser 的查询:

logparser -i:Textline "SELECT TO_DATE(TO_TIMESTAMP(TRIM(EXTRACT_SUFFIX(text,0,'TIMESTAMP')),'M/d/yyyy'))AS DATE, TO_TIME(TO_TIMESTAMP(TRIM(EXTRACT_TOKEN(text,0,'(')),'H:mm:ss')) as TIME from 'C:\xxxx.log' where text like '%OUT:%' OR text like '%IN:%' OR text like '%TIMESTAMP%' OR text like '%DENIED%'" -o:datagrid

查询的输出是:

DATE           TIME
NULL           03:09:49
NULL           03:09:49
NULL           03:10:44
NULL           03:11:52
2015-02-06     03:12:40
NULL           03:13:37
NULL           03:18:22
NULL           03:21:18
NULL           03:21:32
NULL           03:24:19
NULL           03:26:02

当我希望此数据流入 SQL table 时,出现以下错误:

查询:

logparser -i:Textline "select TO_DATE(TO_TIMESTAMP(TRIM(EXTRACT_SUFFIX(text,0,'TIMESTAMP')),'M/d/yyyy'))AS DATE, TO_TIME(TO_TIMESTAMP(TRIM(EXTRACT_TOKEN(text,0,'(')),'H:mm:ss')) as TIME INTO Ptclog from 'C:\ptclmgrd.log' where text like '%OUT:%' OR text like '%IN:%' OR text like '%TIMESTAMP%' OR text like '%DENIED%'" -o:SQL -server:KANNA\SQLEXPRESS -database:Flex -driver:"SQL Server Native Client 11.0" -username:sa -password:XXXXXX

错误:

任务中止。 SQL table 列 "Time" 数据类型与 SELECT 子句项不兼容 "TIME"(类型时间戳)

在 SQLEXPRESS 中 select 的数据类型是

time(0).

如果我 select 数据类型为 :

,则数据流向该列

"datetime"

但这会在时间前面添加一个默认日期,这很麻烦。例如时间显示为:

DATE        TIME
2015-02-06  2015-01-01 03:12:40.000
NULL        2015-01-01 07:55:49.000
NULL        2015-01-01 06:46:50.000
NULL        2015-01-01 06:55:40.000
NULL        2015-01-01 01:57:25.000
NULL        2015-01-01 02:36:41.000

有没有办法在 sql express 2014 DB 中以 hh:mm:ss 格式表示时间?

以下是正在查询的日志文件中的示例条目:

3:12:40 (lmgrd) TIMESTAMP 2/6/2015
3:13:37 (ptc_d) OUT: "PROE_Flex3CG" e1cx@D43F2STC  
3:18:22 (ptc_d) OUT: "PROE_Flex3C" u234566@D5712Sf8  
3:21:18 (ptc_d) OUT: "PROE_Flex3C" u234566@D5712Sf8  
3:21:32 (ptc_d) OUT: "PROE_Flex3C" U524863@D9NR972S  
3:24:19 (ptc_d) IN: "PROE_Flex3CG" e1cx@D43F2STC  
3:26:02 (ptc_d) OUT: "PROE_Flex3C" m0ax@2SD3TC3F  
3:26:46 (ptc_d) OUT: "PROE_Flex3C" 06u1015@03tjn-proe  
3:26:48 (ptc_d) OUT: "26" 06u1015@03tjn-proe  
3:26:48 (ptc_d) OUT: "10114" 06u1015@03tjn-proe  
4:34:39 (ptc_d) DENIED: "26" 74U1027@MZBOXSGH61108  (Licensed number of users already reached. (-4,342:10054 ""))

很遗憾,LogParser 不支持时间类型。您可以尝试将 DATE 和 TIME 列作为单个 Datetime 一起发送,或者将 TIME 列作为字符串发送并希望 SQL 服务器将其转换为 Time...