MSSQL money datatype and <cfqueryparam/>

This is just a quick post about the <cfqueryparam/> and cf_sql_type to use with when working with Microsoft SQL Server (MSSQL) money datatype.

2 responses so far ↓

Henry Ho - Apr 7, 2011 at 5:10 PM

cf_sql_float for money? really? doesn't make sense.

cf_sql_money and cf_sql_money4 should work, if they don't, they should be reported as bug if it is easily reproducible?

Craig Kaminsky - Apr 7, 2011 at 5:21 PM

Hi, Paul,

For what it's worth, I've used <cfqueryparam cfsqltype="cf_sql_money" ... /> with no issues on CF8, CF9 and Railo. As Henry noted, they should work for you, too.

The timing of your post is interesting! Just yesterday, I ran into a point of uncertainty with the money data type and ORM. I wasn't sure what ormtype to use for it when setting the property in the CFC.

Long and short, I found that in such scenarios, you should use big_decimal as the value for your ormtype attribute in the property 'tag'.

property name="mymoneyfield" type="numeric" ormtype="big_decimal" ...;

When I tried double and float, SQL Server would convert my money values (e.g., 14.29 would become 14.29956837 or something like that!).

Anyway, didn't mean to go off-topic but thought I mention how to assign an ormtype for your money fields in SQL Server.

Leave a Comment

Leave this field empty: