How to capture the SQL statement after parameter substitution?

  • Thread starter Thread starter John Dalberg
  • Start date Start date
J

John Dalberg

I am getting a "String or binary data would be truncated. The statement has
been terminated" error. I am trying to capture the exact SQL statement
that's causing the error but SQL Server's profiler doesn't have it and if I
capture the commandtext property of SQLCommand, the sql has the parameters
without substitution.

How do I capture the exact SQL after parameters substitution? It seems one
of the parameter values is too long to fit.
 
If the Profiler did not "get it" then this is a client-side problem with
ADO.NET. Nope, I don't know of a way to "see" the compiled SQL post
parameter insertion (other than what the Profiler shows). Since you're using
a Command with Parameters you'll need to trace through the Value set
statements to see which has a value outside of the desired range.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
Back
Top