SQL Server - 如何找出删除密钥的人?

时间:2015-03-09 01:57:54

标签: sql sql-server

只是想知道是否有一个日志/审计表来保存信息,比如哪些用户创建/更改/删除了密钥或索引等?

1 个答案:

答案 0 :(得分:1)

默认跟踪捕获DDL更改。下面是一个收集这些信息的例子。

--Object:Created and Object:Altered events from default trace
SELECT 
     te.name AS EventName
    ,tt.StartTime as st
    ,tt.DatabaseName
    ,tt.ObjectName
FROM sys.traces AS t
CROSS APPLY [fn_trace_gettable](t.path, DEFAULT) AS tt
JOIN sys.trace_events AS te ON
    te.trace_event_id = tt.EventClass
WHERE 
    tt.EventClass in (46,164)
    AND tt.EventSubClass = 0
ORDER BY st DESC;