根据https://blog.csdn.net/yeluo_vinager/article/details/106147019
日志导入到SQLServer 以后时间是UTC格式
而且日期和时间分开了,导出到SQLSERVER时,会生成二个字段
把UTC时间换成本地时区的时间 有两个方式
一、SQL Server sql语句转换
alter table [MyTestDb][db][MyMVC_WebLog] add RequestTime datetime
go
update [MyTestDb][db][MyMVC_WebLog] set RequestTime=dateadd(hh,8,convert(varchar(10),date,120)
+ ' ' + convert(varchar(13),time,114))
二、logparser导出转换
logparser.exe "SELECT TO_LOCALTIME(TO_TIMESTAMP(ADD(TO_STRING(date, 'yyyy-MM-dd '), TO_STRING(time, 'hh:mm:ss')), 'yyyy-MM-dd hh:mm:ss')) AS RequestTime, * FROM 'D:\Log\u_ex200515.log' to MyMVC_WebLog2" -i:IISW3C -o:SQL -oConnString:"Driver={SQL Server};server=localhost;database=MyTestDb;Integrated Security=SSPI"-createtable:ON