[freetds] 'Money' column types need an explicit convert

James K. Lowden jklowden at freetds.org
Mon Aug 14 21:16:19 EDT 2006

Daniel Kasak wrote:
> DBD::ODBC::db prepare failed: [unixODBC][FreeTDS][SQL
> Server]Statement(s) could not be prepared. (SQL-42000)
> [unixODBC][FreeTDS][SQL Server]Disallowed implicit conversion from data
> type varchar to data type money, table 'NUSsql.dbo.Clients', column
> 'DisputeAmount'. Use the CONVERT function to run this query.
> (SQL-42000)(DBD: st_prepare/SQLPrepare err=-1) at
> .client_services/modules/common.pm line 108
> I can deal with the problem - I'll either convert the column to
> something other than money, or add a covert() function if I detect a
> 'money' column type. Anyway, the question is: is this a bug or a
> feature? 

I think that's a server message.   Try this query:

	select cast(1 as money) as 'a' union select '2'

You should get:

Msg 257, Level 16, State 3
Implicit conversion from data type varchar to money is not allowed. Use
CONVERT function to run this query.

(The character value '2' is implicitly converted to the datatype (money)
established by the first part of the UNION.)

You said it's a "simple update" statement, indicating that somewhere
you're pointing quotes around a numeric value or storing a number in a
variable declared as char/varchar.  Stop doing that and you'll be OK.  ;-)

If you're binding to a character host variable, similar restrictions



More information about the FreeTDS mailing list