I've used this function to view the SQL with the param data in place.

<cffunction name="executedSQL">

        <cfargument name="result">

        <cfset var LOCAL = {}>

        <cfset LOCAL.sqlString = ARGUMENTS.result.sql>

        <cfif StructKeyExists(ARGUMENTS.result, "sqlParameters")>
                <cfset LOCAL.params = ARGUMENTS.result.sqlParameters>
                <cfloop array="#LOCAL.params#" index="LOCAL.param">
                        <cfif NOT IsNumeric(LOCAL.param)>
                                <cfset LOCAL.param = "'" & LOCAL.param & "'">
                        </cfif>
                        <cfset LOCAL.sqlString = ReplaceNoCase(LOCAL.sqlString, 
"?", LOCAL.param,
"ONE")>
                </cfloop>
        </cfif>

        <cfreturn "<pre>" & LOCAL.sqlString & "</pre>">

</cffunction>

<cfquery name="testQuery" datasource="yourDS" result="r">
        SELECT *
        FROM myTable
        WHERE myColumn = <cfqueryparam cfsqltype="CF_SQL_INTEGER"
value="#someVar#">
        AND myOtherColumn = <cfqueryparam cfsqltype="CF_SQL_VARCHAR"
value="#anotherVar#">
</cfquery>

<cfoutput>#executedSQL(r)#</cfoutput>

Adrian
www.adrianlynch.co.uk

-----Original Message-----
From: Brad Wood [mailto:[EMAIL PROTECTED]
Sent: 22 July 2008 21:46
To: CF-Talk
Subject: Re: cfquery and cfstoredproc

> In all versions of CF, cfqueryparam effectively makes Sql Profiling with
> SQL Server useless and there is no workaround.

Please explain what you mean.  Are you saying you can't run a trace and see
your SQL running.  That is certainly not true.  It may complicate seeing the
valuf of your input parameters.  peronally I use SeeFusion to watch my SQL
traffic.  I can debug a single users's IP and it shows me all the parameters
being passed in.

~Brad


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:309481
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to