471,356 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,356 software developers and data experts.

Parameterized Query

Is there a way to see the exact SQL being generated from a
parameterized query? I am using this technique but am getting some
strange SQL errors during execution and I would like to see the final
SQL that is being generated.
Jun 27 '08 #1
3 2107
xlar54 wrote:
Is there a way to see the exact SQL being generated from a
parameterized query? I am using this technique but am getting some
strange SQL errors during execution and I would like to see the final
SQL that is being generated.
A parameterized query doesn't generate any other sql, the query is sent
as-is to the database engine along with the parameter values, and the
database engine puts them all together.

In short, unless you're using a database that actually rewrites the sql
with the parameter values verbatim, you won't get what you're asking for.

--
Lasse Vågsæther Karlsen
mailto:la***@vkarlsen.no
http://presentationmode.blogspot.com/
PGP KeyID: 0xBCDEA2E3
Jun 27 '08 #2
Just additional - most database enginers come with a trace/profiler
facility that can be used to see the final SQL statements. This is handy
when the code is auto-generated (LINQ-to-entities for example), but I
agree with the last reply: in this case it sounds like it will be sent
verbatim.

Marc
Jun 27 '08 #3
"xlar54" <sc**********@gmail.comwrote in message
news:cd**********************************@m73g2000 hsh.googlegroups.com...
Is there a way to see the exact SQL being generated from a
parameterized query? I am using this technique but am getting some
strange SQL errors during execution and I would like to see the final
SQL that is being generated.
If you are using Microsoft SQL Server, it includes a tool "SQL Server
Profiler". If you run it, it will let you capture all the SQL that the
server is receiving from the client. You may find it useful to examine the
calls that the client is sending to the server. As others replied before,
you will find out that the parameterized query is sent "as is", along with
the values of the parameters.

Jun 27 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Bill George | last post: by
1 post views Thread by Jorell | last post: by
1 post views Thread by TF | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.