SQL Profiler使用哪些API? [英] What are the APIs used by SQL Profiler?
问题描述
SQL Server Profiler显示针对SQL Server实例正在执行的命令的实时流.用来捕获这些数据的API是什么?
SQL Server Profiler displays a live stream of commands being executed against a SQL server instance. What are the APIs used to capture this data?
背景:我需要编写一个小实用程序(在C ++中),该实用程序可以跟踪由单独的应用程序发出的SQL命令.
Background: I need to write a small utility (in C++) which tracks the SQL commands being issued by a separate application.
推荐答案
Here on the API Development Team Blog is a quick C# (should be easy to convert to c++) program which connects to SQL Server and shows the text of all starting batches in real time as the requests are coming to SQL Server.
例如链接中的代码段
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"]);
如Alex所述,您将需要使用 TraceServer API.
As Alex mentioned, you will need to use the TraceServer API.
这篇关于SQL Profiler使用哪些API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!