Logging ODBC, SQL Server
How to log, trace or get querie开发者_开发百科s 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?
@davispuh, you can use the SQL Profiler to trace SQL statements. you can also use the ODBC Tracing.
To Create a Trace using SQL-Profiler:
- On the File menu of SQL-Profiler, click New Trace, and connect to an instance of SQL Server. The Trace Properties dialog box appears.
- In the Trace name box, type a name for the trace.
- 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.
- 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:
- Profile Driver Performance Data (ODBC)
- Log Long-Running Queries (ODBC)
Hope this helps.
精彩评论