How to display sql query in web browser
Copy link to clipboard
Copied
Please let me know how to display the query written in cold fusion page on web browser.
Copy link to clipboard
Copied
I'm not entirely clear what you're asking. If you want to output the actual SQL statement, it's a property of the CFQUERY resultset, like so:
<cfquery name="sample" result="sampleResult" ...>
select * from tblSample
</cfquery>
<cfoutput>#sampleResult.sql#</cfoutput>
If on the other hand, you want to output the resultset itself, you use the QUERY attribute of CFOUTPUT:
<cfquery name="books" ...>
select bookId, name, author from tblBooks
</cfquery>
<cfoutput query="books">
#name#, #author#<br>
</cfoutput>
Dave Watts, Eidolon LLC
Copy link to clipboard
Copied
ColdFusion comes with a built-in datasource called cfartgallery. So, if you open the following page, it will display the query in the browser.
testPage.cfm
<cfquery datasource="cfartgallery" name="testQuery">
select *
from artists
</cfquery>
<cfdump var="#testQuery#">
Copy link to clipboard
Copied
Thank a lot BKBK and others for the solutions provided by you all. I am trying to print the dynamic query which i will writing in my .cfm page on to the browser. Will test the sample code provided by BKBK.

