Blank Coldfusion errors on Query of Queries using like clause

[Macromedia][SQLServer JDBC Driver]Value can not be converted to requested type.

If you have a string column that contains a null value, this occurs. You have to add a check for the null first. Note that the like clause is also case sensitive for query of queries.

Breaks:

SELECT * FROM myTable
WHERE 1=1
AND LOWER(name) LIKE <cfqueryparam cfsqltype=”cf_sql_varchar” value=”%#LCase(searchCriteria.search)#%” />

Works:

SELECT * FROM myTable
WHERE 1=1
AND name is not null AND LOWER(name) LIKE <cfqueryparam cfsqltype=”cf_sql_varchar” value=”%#LCase(searchCriteria.search)#%” />

Leave a Reply

Your email address will not be published. Required fields are marked *