I'v come up with this and it works rather nicely...

<cfset qryOptions = QueryCastColumn(qryOptions, "column", "varchar")>


<cffunction name="QueryCastColumn">
        <cfargument name="query" type="query" required="Yes">
        <cfargument name="column" type="string" required="Yes">
        <cfargument name="type" type="string" required="Yes">

        <!--- Duplicate the inbound query --->  
        <cfset myQuery = duplicate(arguments.query)>
        
        <!--- Remove column from the field list --->
        <cfset strColumnList = myQuery.columnList>
        <cfset strColumnList = listDeleteAt(strColumnList,
listFindNocase(strColumnList, arguments.column))>
        
        <!--- Create new cast selector --->
        <cfset strSelector = "cast([#arguments.column#] as
#arguments.type#) as [#arguments.column#]">
        <cfset strSelector = listAppend(strSelector, strColumnList)>

        <!--- Get newly cast query --->
        <cfquery name="myQuery" dbtype="query">
        select
                #preserveSingleQuotes(strSelector)#
                from myQuery
        </cfquery>
        
        <cfreturn myQuery>
</cffunction>

Hope someone else can make use of it.

Martin Parry
Macromedia Certified Developer
http://www.BeetrootStreet.co.uk


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:194208
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to