tags:

views:

113

answers:

3

Is there a tool for windows that we can use to inspect any SQL commands that go through a particular ODBC data source?

+6  A: 

You can make ODBC log out everything it's doing:

http://support.microsoft.com/kb/274551

http://msdn.microsoft.com/en-us/library/ms711020%28VS.85%29.aspx

You can also do it programmatically:

... One can do this by calling SQLSetConnectAttr and set the SQL_ATTR_TRACE attribute in the connection to SQL_OPT_TRACE_ON. So, by doing this you would be enabling/disabling it for the connection duration.

http://decipherinfosys.wordpress.com/2009/01/17/odbc-tracing/

Tim Sylvester
Yes I found this info before, but i was not able to get it to work when I enable it. no log file is created even though tracing is on. So I thought maybe there is a 3rd party tool out there that will just work out of the box.
Roberto Sebestyen
It has always "just worked out of the box" for me. Maybe you should create a question on SuperUser to solve the tracing problem. Have you tried re-installing ODBC, MDAC, etc.? Unfortunately, I don't know of any other software that does the same thing.
Tim Sylvester
A: 

If you're using SQL Server, look at the SQL Server Profiler. Profiler allows you to monitor/trace all communications between your application and the SQL Server, including which procedures are called, parameter values, etc, without having to modify your application.

If you're using a different server, you should be able to find a sql proxy that will do the same thing.

David Lively
+1  A: 

Generally it is advisable that your ODBC application not be running when you enable ODBC tracing, such that when it starts it can pick up the tracing option having been enabled and then perform the tracing.

Note OpenLink Software provide an ODBC tracing tool calle OpenLink Scan for providing detailed ODBC tracing and Metadata analysis on 32bit windows, which can be downloaded from:

http://download.openlinksw.com/download/login.vsp?pfam=6&pform=1&pcat=16&prod=odbc-scan&os=i686-generic-win-32&os2=i686-generic-win-32&xpfam=utilities&xpform=enterprise&xpcat=diagnostictools&xos=i686-generic-win-32&release-dbms=1.0-nodb

Best Regards

OpenLink Software

hwilliams