When Quotes Matter

By |2018-06-24T14:49:50+00:00January 23rd, 2016|Code|0 Comments

I am a big fan of the script capabilities of CF 11 and especially queryExecute(). If you are using it, make sure all your SQL is wrapped within double quotes so that string values work and you don’t end up troubleshooting simple issue because of vague errors.

Take this example

I originally made the error of using single quotes which tends to be my preference, but ended up with an error of ColdFusion is looking at ‘VM’ and has experienced an error. So I changed it to “VM” (forgetting basic SQL rules) which threw a SQL error “Could not find column VM.”  Using the basic rule of double quotes on the outside, single quotes on the inside will help you avoid these issues.

For what it is worth, this is a query of a Microsoft System Center database to retrieve physical and virtual machines.

 

Leave a Reply