Will,
The only problem I see is that you do not need to <cfqueryparam> the value of your order by clause since it is not a valid field value. You do not need it, and cannot do it on column names or sql functions. Doug -----Original Message----- From: Will Tomlinson [mailto:[EMAIL PROTECTED] Sent: Sunday, March 04, 2007 10:25 AM To: CF-Talk Subject: can't <cfqueryparam> order by? I'm letting users filter by specific columns, including ORDER BY... So I naturally <cfqueryparam>'d it and got this error: Error Executing Database Query. [Macromedia][SQLServer JDBC Driver][SQLServer]The SELECT item identified by the ORDER BY number 1 contains a variable as part of the expression identifying a column position. Variables are only allowed when ordering by an expression referencing a column name. <cfquery name="getProducts" datasource="#APPLICATION.dsn#"> SELECT tblMusicProducts.musicprodID, tblMusicProducts.musicprodname, tblMusicProducts.musicprodprice, tblMusicProducts.musicprodimagethumb, tblMusicProdTypes_X.musicprodID, tblMusicProdTypes_X.musicprodtypeID, tblMusicProdTypes.musicprodtypeID, tblMusicProdTypes.musicprodtypename FROM tblMusicProducts, tblMusicProdTypes_X, tblMusicProdTypes WHERE tblMusicProdTypes.musicprodtypeID = <cfqueryparam cfsqltype="cf_sql_integer" value="#URL.TYPE#"> AND tblMusicProducts.musicprodID = tblMusicProdTypes_X.musicprodID AND tblMusicProdTypes.musicprodtypeID = tblMusicProdTypes_X.musicprodtypeID ORDER BY <cfqueryparam cfsqltype="cf_sql_varchar" value="#order#"> </cfquery> If I remove the cfqueryparam, it works fine. I guess it's doing this because I'm including ASC and DESC in the variable. I'm creating a statement IN a variable basically. What's the best practice for doing this. I'm obviously goin about it the wrong way. Thanks, Will ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Create Web Applications With ColdFusion MX7 & Flex 2. Build powerful, scalable RIAs. Free Trial http://www.adobe.com/products/coldfusion/flex2/ Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:271450 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

