Log SQL statements in Dynamics GP
This is based on the original Microsoft article Reference: KB850996
When working with Microsoft Dynamics GP you sometimes need to know what databse operations are going on under the hood, to diagnose issues or understand which database objects it is interacting with. I experienced this again recently when installing Collections Management where the installer was giving me a SQL error.
By enabling the Dexsql.log file to capture the exact SQL activity at the point an error occurs, gives you diagnostic information needed to resolve the issue or gain the understanding you need for reports or building modifications.
Enable Logging in Dex.ini
Open the Dex.ini file, located at:
C:\Program Files\Microsoft Dynamics\GP\Data\Dex.ini
Find the following three settings and change them from FALSE to TRUE:
| Setting | Default | Change To |
|---|---|---|
SQLLogSQLStmt |
FALSE |
TRUE |
SQLLogODBCMessages |
FALSE |
TRUE |
SQLLogAllODBCMessages |
FALSE |
TRUE |
Save the file.
Restart Microsoft Dynamics GP
Fully exit and relaunch Dynamics GP so the new logging settings take effect.
Clear the Log before executing the action of interest
Sign in to GP and navigate to the point just before you wish to investigate. In Windows Explorer, go to the GP application folder and delete or rename the Dexsql.log file that has already been generated this just makes it easier to see the wood for the trees, letting you focus on the part of interest.
Do "the thing"
Return to Dynamics GP and complete the steps that trigger the operation of interest. A fresh Dexsql.log will be written to the GP application folder containing the SQL information.
Important - Disable Logging
It is really important to turn logging off afterwards. The logging can impact GP application performance and also can the log can grow huge.
Once you have the log, reopen Dex.ini and reset the settings back to FALSE:
| Setting | Reset To |
|---|---|
SQLLogSQLStmt |
FALSE |
SQLLogODBCMessages |
FALSE |
SQLLogAllODBCMessages |
FALSE |