Re: Smallmoney and money rounded to 2 decimals?
Frediano Ziglio <[email protected]> Thu, 12 Apr 2018 08:41:35 +0100
| Newsgroups | gmane.comp.db.tds.freetds |
|---|---|
| Message-ID | <CAHt6W4d7z-4Djcwia5NX9=99yc3S7AMVJAtg68rZKHM4LwxQ2A@mail.gmail.com> |
2018-04-06 12:59 GMT+01:00 Sebastien FLAESCH <[email protected]>: > Hi all, > > Using FreeTDS 1.00.9: > > When fetching a smallmoney or money data, SQLDescribeCol() returns > the sqltype SQL_DECIMAL, precision 10 for smallmoney and or 19 for > money and a scale of 4 for both types, which is fine, since smallmoney > and money can store 4 decimal digits. > > Using an SQL_C_CHAR buffer to hold the values, we see that the decimal > part is rounded to 2 digits... > > Is this expected? > > using other ODBC drivers for SQL Server we get 4 decimal digits. > > Is there some configuration settings to control this? > > Thanks! > Seb Just checked. Yes, apparently Microsoft ODBC drivers format money with 4 decimal digit. I think in the past tools used 2 digits but they moved to 4 along the way. There's actually no way to change that behavior but probably there should be. The 2 digits code is currently quite hard coded in src/tds/convert.c and src/tds/numeric.c. I suppose a good way would be to add a flag to TDSCONTEXT (which is used during conversion to pass locale information). Frediano