Follow up. You are absolutely correct. With scale set to 2 the dec. works as described the float would require manipulation that would be unnecessary. I will change my DB also.
on 5/24/02 10:51 AM, Eric Weidl at [EMAIL PROTECTED] wrote: > Hi, > >> I beg to differ at least with SQL 2000 > > You can beg all you want, but FLOAT is the wrong data type to use. ;-) > > If you don't believe me, believe Microsoft. Read the SQL Server Documentation: > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/acdata/ac_8_c > on_03_6mht.asp > > >> I just ran a test >> Data Type Entered Result >> Money 20.30 20.3 >> Decimal -prec2 20.30 2 >> Decimal - prec 4 20.30 2 >> Float 20.30 20.30 > > Clearly, something is wrong with your configuration. No programmer on earth > should accept the fact that entering "20.30" returns "2". > > And I know what the problem is. Everyone can make mistakes, including me! I > said "precision of 2". I meant "scale of 2". Precision is the total number > of bytes (digits) to use to store the column value. Scale is the number of > digits to the *right of the decimal point*. A column's Scale must always be > less than its Precision. > > Create this table in SQL Server: > > CREATE TABLE [dbo].[DataTypes] ( > [aMoney] [money] NULL , > [aFloat] [float] NULL , > [aDecimal2] [decimal](18, 2) NULL , > [aDecimal4] [decimal](18, 4) NULL > ) > > Using the Enterprise Manager, enter 20.30 as the value for each column. > > Create a new ODBC data source pointing to the database. *MAKE SURE YOU DO > NOT CHANGE THE ANSI PADDINGS SETTING WHEN SETTING UP THE DATA SOURCE.* > > Create a new TAF. Add one Direct DBMS action. Enter: > > SELECT * FROM DATATYPES > > in the SQL Query. Enter <@VAR resultSet> in the Results HTML. Run the TAF > from your browser. Here's what I get: > > 20.3000 20.300000000000001 20.30 20.3000 > > Notice the trailing 1 on the float column value. I'll say once again (in > case you didn't believe Bill's minions) Floats are *approximate*! > > >> USE FLOAT!!! > > No, do not use float for this type of data. > > If the issue is the trailing 0, then it is a padding issue. Using the wrong > data type as a "fix" for improper padding is like using a hammer to drive > in a screw. > > Eric > > > ________________________________________________________________________ > TO UNSUBSCRIBE: send a plain text/US ASCII email to [EMAIL PROTECTED] > with unsubscribe witango-talk in the message body > -- Dan Stein Digital Software Solutions 799 Evergreen Circle Telford PA 18969 215-799-0192 610-256-2843 Fax 413-410-9682 FMP,Tango, EDI,SQL 7 [EMAIL PROTECTED] www.dss-db.com ________________________________________________________________________ TO UNSUBSCRIBE: send a plain text/US ASCII email to [EMAIL PROTECTED] with unsubscribe witango-talk in the message body
