I need to select a row where identifier matches my variable. Let's say, my variable value is "myvariable" (in uniqueidentifier form, of course).
<cfset current_user_id = "myvariable">
Here's my "cfquery" content:
<cfquery name="findUser" datasource="#SOURCE#">
SELECT
db.[User].UserID
FROM
db.[User]
WHERE
db.[User].UserID = "#current_user_id#";
</cfquery>
It returns the following error:
[Macromedia][SQLServer JDBC Driver][SQLServer]Invalid column name 'myvariable'.
The data and query is fine. A cfdump of SELECT * returns all of the rows, but the addition of the WHERE clause causes an error. The query works fine, outside ColdFusion, even with WHERE clause.
I tried adding this, but it doesn't work either:
<cfqueryparam value = "#current_user_id#" cfsqltype="cf_sql_idstamp">
Is there something I should know about selecting the "uniqueidentifier" type with conditions? Maybe I need to set the type of my variable to "uniqueidentifier" somehow?
CF version 10,0
Thank you in advance!
'#current_user_id#'. The cfqueryparam looks OK - do you get the same error with that or a different error? Also which CF version are you using - you've tagged 9, 10 & 11 - John Whish