Prevent SQL Server's Profiler trace software _mssql

Source: Internet
Author: User
The two methods have the same principle
The first method:
Copy Code code as follows:

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
Stop all SQL Server's trackers to prevent the program from being tracked by someone else
Execsql (SQL);
End

The second method:
Copy Code code as follows:

with FAQ1 does
begin
Close;
SQL. Clear;
Sql.add (' Declare @t_count int ');
Sql.add (' Set @t_count = 1 ');
Sql.add (' while exists (SELECT *:::: 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;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.