Logging ODBC, SQL Server

末鹿安然 提交于 2019-12-21 14:58:27

问题


How to log, trace or get queries that an application send to Microsoft SQL Server 2008 thru ODBC driver (without modifying application...)

Maybe it can be done with SQL Server itself or ODBC has some query logging?


回答1:


@davispuh, you can use the SQL Profiler to trace SQL statements. you can also use the ODBC Tracing.




回答2:


To Create a Trace using SQL-Profiler:

  1. On the File menu of SQL-Profiler, click New Trace, and connect to an instance of SQL Server. The Trace Properties dialog box appears.
  2. In the Trace name box, type a name for the trace.
  3. In the Use the template list, select a trace template on which to base the trace, or select Blank if you do not want to use a template.
  4. If you do not use a template you can hit the Show all Events checbox and choose which events you would like to trace, there you can choose if errors, logins etc are traced. For more information take alook at: Specify Events and Data Columns for a Trace File (SQL Server Profiler) for Example you have a category there Errors and Warnings which include special Error events.

For more information see the documentation

If you need to do this for ODBC you can check the following two topics:

  1. Profile Driver Performance Data (ODBC)
  2. Log Long-Running Queries (ODBC)

Hope this helps.



来源:https://stackoverflow.com/questions/2732985/logging-odbc-sql-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!