ADO - Stored Procedure - Generated SQL

ADO - Stored Procedure - Generated SQL
Is there a way to intercept and view the generated SQL of a stored procedure call?
We have a strange date off by 2 issue.

#sql

Comments

  1. If it's mssql Why don't you use the Sql profiler in Ssms

    ReplyDelete
  2. Good point, Peter Joseph - Also just rediscovered that we have no less than five methods of firing stored procs in our wrappers, all processing arguments in different ways.

    ReplyDelete
  3. Double-check the parameters datatype: we had this problem when the parameter was interpreted as a double and not as a TDateTime. During the call, the date was converted to float, passed to the server  as a float and re-converted to a sql datetime. This leads to the 2 day offset, since in delphi TDateTime(0) = '1899-12-30' and in mssql cast(0 as datetime) = '1900-01-01'

    ReplyDelete
  4. Giacomo Degli Esposti - That was indeed the problem.  What fixed it was formatting the date as a string in the format that the db was set up for.  The developer said "Don't tell anyone" as  this was the method used numerous other places in the code :)  The underlying cause appears to be that TDateTime turns to Double in a Variant array.

    ReplyDelete
  5. Lars Fosdal LOL. Don't worry, this will stay a secret between you and me! ;-)

    ReplyDelete

Post a Comment