SQL Server 默认跟踪应用3 -- 检测对表的DDL操作
在SQL Server数据库上发生的DDL操作,能知道是谁做的么?是的。SQL Server默认跟踪有对象修改事件。
这个脚本列出所有的对象修改事件。查询条件中加上时间和数据库名的限制。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
select e.name as eventclass,
t.loginname,
t.spid,
t.starttime,
t.textdata,
t.objectid,
t.objectname,
t.databasename,
t.hostname,
t.ntusername,
t.ntdomainname,
t.clientprocessid,
t.applicationname,
t.error
FROM sys.fn_trace_gettable(CONVERT(VARCHAR(150), ( SELECT TOP 1f.
FROM sys.fn_trace_getinfo(NULL) f WHERE f.property = 2)), DEFAULT) T
inner join sys.trace_events e on t.eventclass = e.trace_event_id
where eventclass=164
页:
[1]