What are the APIs used by SQL Profiler?

The SQL Server Provider displays a direct stream of commands executed against an instance of SQL Server. What APIs are used to capture this data?

Background: I need to write a small utility (in C ++) that monitors SQL commands issued by a separate application.

+2


a source to share


3 answers


Here the API Developers Blog is a fast C # program (should be easy to convert to C ++) that connects to SQL Server and shows the text of all starting batches in real time as requests come in to SQL Server.

eg. Snippet of code from link



Console.WriteLine("Event : " + trace["EventClass"]);
Console.WriteLine("SPID  : " + trace["SPID"]);
Console.WriteLine("Login : " + trace["SessionLoginName"]);
Console.WriteLine("Object: " + trace["ObjectName"]);
Console.WriteLine("Text  : " + trace["TextData"]);

      

As Alex said, you will need to use the TraceServer API .

+1


a source


I don't know how Profiler works, but they are displayed through the TraceServer API.



+1


a source


This blog post describes the Trae Management Object (TMO) and how to use it.

A handy profiling tool using this TMO can be found at HERE

+1


a source







All Articles