Skip to Content.
Sympa Menu

freetds - Re: [freetds] MONEY type support??

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT freetds.org>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] MONEY type support??
  • Date: Mon, 18 Dec 2006 11:01:42 -0500

Sokol, Ryan - 244 wrote:
> Anyway to NOT have the client round it?

We know now that's basically a PHP question, because PHP is the client (as
far as FreeTDS is concerned) and PHP converts most datatypes to strings.
Because PHP (I assume) uses the db-lib dbconvert() function, it gets a
result rounded to two places.

Answer is not to have your query return MONEY columns when you don't want
this behavior. I suggest "CAST(mycol to NUMERIC(p,s)) as mycol",
substituting of course your preferred values for precision and scale.
>From the docs:

"Monetary data values from -2^63 (-922,337,203,685,477.5808) through
2^63 - 1 (+922,337,203,685,477.5807), with accuracy to a ten-thousandth of
a monetary unit. Storage size is 8 bytes."

That looks like numeric(20,4) to me. You can also use the T-SQL CONVERT
function, passing a style of '2' i.e.:

convert(varchar(22), mycol, 2) as mycol

That should do the trick. Cf.
http://msdn2.microsoft.com/en-us/ms187928.aspx for details.

HTH.

--jkl

> -----Original Message-----
> From: freetds-bounces AT lists.ibiblio.org
> [mailto:freetds-bounces AT lists.ibiblio.org] On Behalf Of
> michael.peppler AT bnpparibas.com
> Sent: Monday, December 18, 2006 12:51 AM
> To: freetds AT lists.ibiblio.org
> Subject: Re: [freetds] MONEY type support??
>
> Actually, MONEY is fixed point, with 4 decimal places. The client almost
>
> always rounds this to two decimal places, though.




Archive powered by MHonArc 2.6.24.

Top of Page