防止SQLSERVER的事件探查器跟踪软件方法,两种方法的原理相同,需要的朋友可以看下。
两种方法的原理相同
第一种方法:
代码如下:
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;
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn