1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
-- 注意:event_time 使用的是 UTC 时间,所以要加上当地时区的差值 SELECT CONVERT(datetime, SWITCHOFFSET(CONVERT(datetimeoffset, f.event_time), DATENAME(TZoffset, SYSDATETIMEOFFSET()))) AS event_time, f.sequence_number, f.action_id, a.name AS action_name, f.succeeded, f.session_server_principal_name, f.server_principal_name, f.database_name, f.object_id, f.schema_name, f.object_name, f.class_type, m.class_type_desc, f.statement FROM sys.fn_get_audit_file('E:\sql_audit\*',default,default) f INNER JOIN sys.dm_audit_actions a ON f.action_id=a.action_id INNER JOIN sys.dm_audit_class_type_map m ON f.class_type=m.class_type WHERE f.object_name='news_info' AND CONVERT(datetime, SWITCHOFFSET(CONVERT(datetimeoffset, f.event_time), DATENAME(TZoffset, SYSDATETIMEOFFSET())))>'2020-03-11 12:00:00' ORDER BY f.event_time; -- 或者 SELECT * FROM sys.fn_get_audit_file('E:\sql_audit\*',default,default) f WHERE f.object_name='news_info' ORDER BY f.event_time; |