Logging Odbc, SQL Server

Logging ODBC, SQL Server

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

ODBC Logging of Requests

How about:

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Office\14.0\Access Connectivity Engine\Engines\ODBC]

Values:

"TraceODBCAPI"=dword:00000000
"DisableAsync"=dword:00000001

"TraceSQLMode"=dword:00000000

"QueryTimeout"=dword:0000003c
"LoginTimeout"=dword:00000014
"ConnectionTimeout"=dword:00000258
"TryJetAuth"=dword:00000000
"FatBlastRows"=dword:ffffffff
"FatBlastTimeout"=dword:00000003
"AsyncRetryInterval"=dword:000001f4
"AttachCaseSensitive"=dword:00000000
"FastRequery"=dword:00000000
"ODBCISAMAttach"=dword:00000000
"PreparedInsert"=dword:00000000
"PreparedUpdate"=dword:00000000
"SnapshotOnly"=dword:00000000
"AttachableObjects"="'TABLE','VIEW','SYSTEM TABLE','ALIAS','SYNONYM'"

How to log into SQL server with System DSN using Python

put it here for reference, visit this :

https://www.connectionstrings.com/

and find connection string that suits your DSN

HSTMT, UCHAR, SDWORD meaning in ODBC Log

From the article Everything You Want To Know About ODBC Tracing

In the trace log, you’ll see the data type of the handle being
SQLHANDLE, HENV / SQLHENV, HDBC / SQLHDBC, HSTMT / SQLHSTMT. This
value is unique to the particular series of items being called. You
can search in the trace log for this handle number and each call made
on the handle will be shown. This allows you to pick out only the
calls in the trace log that are relevant to your error message. Keep
in mind, some applications may create multiple handles. For example,
your application may execute three statements consecutively with each
residing on a different statement handle.

For examples and more details follow the next nice document:-

How to read an ODBC trace file.rtf

How to get raw query that the ODBC driver tries to execute?

There isn't. To my understanding, that is not how ODBC works: the parameters don't get "expanded" at all and are sent separately to the server.

For your logging situation, simply convert the parameters to strings ad-hoc and insert them in the statement text before writing it out to the log file. That's how we do it in our framework, and it works fine. For some parameter types you'll have to decide whether to favor human-readable logging or copy-paste-able into sql server for reproduction.



Related Topics



Leave a reply



Submit