[Macromedia][SQLServer JDBC Driver][SQLServer]Incorrect syntax near '@P1'.

Posted on September 22, 2009 at 9:43 PM in ColdFusion

This is one of those posts that is definitely for my future reference. You know, one that I will hopefully never ever ever ever ever ever ever ever ever ever need, but will probably do the same stupid thing again anyways. Oh well, hopefully it will help someone else, too.

Run a query and get the following error message:

[Macromedia][SQLServer JDBC Driver][SQLServer]Incorrect syntax near '@P1'.

The answer is ridiculously simple.

  1. WHERE foo IN <cfqueryparam
  2. cfsqltype="cf_sql_varchar"
  3. list="yes"
  4. value="value1,value2,value3" />

At a quick glance - OK, so I took about 80,000 quick glances - I didn't see anything wrong with that. Now what is pathetic is that I have been doing this for 12+ years and I know exactly what is wrong with that, but was in a hurry and didn't see it. Ugh.

Here's the correct code:

  1. WHERE foo IN (<cfqueryparam
  2. cfsqltype="cf_sql_varchar"
  3. list="yes"
  4. value="value1,value2,value3" />)

Perhaps you can spot it.

Comments
(Comment Moderation is enabled. Your comment will not appear until approved.)

On 9/22/09 at 11:29 PM, Don said:

I have forgotten those parens on an IN clause way too many times.

On 1/11/10 at 6:27 PM, Victor said:

I felt very stupid once I found the "simple" solution...
CodeBassRadio

Latest Articles

Eventually something really brilliant and witty will appear right here.

Calendar

June 2026
S M T W T F S
« May  
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30        

Subscribe

Enter a valid email address.

The Obligatory Wish List