Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I retrieve the SQL from a query??

Status
Not open for further replies.

Puc

Programmer
Mar 12, 2001
10
GB
Hi,

Does any body know how to extract the sql from an SQL query in a CFQUERY tag? I am trying to inpect the SQL and would like to know if anyone has been able to do this.

It must be possible, as you can get the SQL when you turn debug on (at the bottom of the screen).

Thanks in advance,

Puc
 
hello..
i don't really get what u mean..
but if u want to retrieve data from sql..
u shl just use the <cfoutput> or <cfloop>tag to display the results from the sql..
 
<cfoutput>

<cfset sqlvar = &quot;your sql string&quot;>
<cfquery datasource= ..........>
#sqlvar#
</cfquery>

</cfoutput>

you can examine the variable sqlvar. Is this you need?
 
ram123 I think that will give him what he needs. If he sets his SQL code in a variable, he can display it to the user where he wants... but I think he's just trying to find a tag that will turn debug output on for any page, without setting anything in the CF admin.

I would think that there would be a tag like this as well. Id love to be able to say

<CFSHOWSQL list=&quot;queryGetNames,queryGetAddresses&quot;>

And see those two queries. As far as I know that's not an option. Anyone know?
 
strantheman has the right idea. Thats what I'd like to be able to do. I just want to be able to inspect the SQL of any query so that I can check it for certain parameters.

If the debug can return the SQL to your debug session, surely this must be available somewhere in CF, some 'special' variable or something.

If anyone knows anymore on this, post it up.

Cheers,

Puc
 
You need to turn on debugging in administrator. enter your IP address in the output to IP from the debug option from the main menu of administrator. This will show you the SQL plus all CGI, form, url variables as well.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top