当前位置: 数据库>sqlserver
防止SQLSERVER的事件探查器跟踪软件
来源: 互联网 发布时间:2014-09-05
本文导语: 两种方法的原理相同 第一种方法: 代码如下: procedure SQLCloseAllTrack; const sql = 'declare @TID integer ' + 'declare Trac Cursor For ' + 'SELECT Distinct Traceid FROM :: fn_trace_getinfo(default) ' + 'open Trac ' + 'Fetch Next From Trac into @TID ' + 'while @@fetch_status=0 ' ...
两种方法的原理相同
第一种方法:
procedure SQLCloseAllTrack;
const
sql = 'declare @TID integer ' +
'declare Trac Cursor For ' +
'SELECT Distinct Traceid FROM :: fn_trace_getinfo(default) ' +
'open Trac ' +
'Fetch Next From Trac into @TID ' +
'while @@fetch_status=0 ' +
'begin ' +
' exec sp_trace_setstatus @TID,0 ' +
' exec sp_trace_setstatus @TID,2 ' +
' Fetch Next From Trac into @TID ' +
'end ' +
'Close Trac ' +
'deallocate Trac';
begin
//停止所有SQLSERVER的跟踪器,以防止程序被別人跟踪
ExecSql(sql);
end;
第二种方法:
with faq1 do
begin
Close;
sql.Clear;
sql.add('declare @t_count int');
sql.add('set @t_count=1');
sql.add('while exists(SELECT * FROM ::::fn_trace_geteventinfo(@t_count))');
sql.add('begin');
sql.add('exec sp_trace_setstatus @t_count,0');
sql.add('set @t_count=@t_count+1');
sql.add('end');
try
execSQL;
except;
end;
close;sql.Clear;
end;
end;
第一种方法:
代码如下:
procedure SQLCloseAllTrack;
const
sql = 'declare @TID integer ' +
'declare Trac Cursor For ' +
'SELECT Distinct Traceid FROM :: fn_trace_getinfo(default) ' +
'open Trac ' +
'Fetch Next From Trac into @TID ' +
'while @@fetch_status=0 ' +
'begin ' +
' exec sp_trace_setstatus @TID,0 ' +
' exec sp_trace_setstatus @TID,2 ' +
' Fetch Next From Trac into @TID ' +
'end ' +
'Close Trac ' +
'deallocate Trac';
begin
//停止所有SQLSERVER的跟踪器,以防止程序被別人跟踪
ExecSql(sql);
end;
第二种方法:
代码如下:
with faq1 do
begin
Close;
sql.Clear;
sql.add('declare @t_count int');
sql.add('set @t_count=1');
sql.add('while exists(SELECT * FROM ::::fn_trace_geteventinfo(@t_count))');
sql.add('begin');
sql.add('exec sp_trace_setstatus @t_count,0');
sql.add('set @t_count=@t_count+1');
sql.add('end');
try
execSQL;
except;
end;
close;sql.Clear;
end;
end;