Home All Groups Group Topic Archive Search About
Author
15 Jul 2005 2:45 PM
rbutch@coair.com
hey guys, need a little advice here. if i want to restrict a column to a decimal precision of 2 - can i do this when i create the table.
and should i use a decimal or float datatype. i just want to force two decimal places.
or do i just allow the datatype to default and then set the precsion when a stored procedure is called with the ROUND(myData,2)?
i've been using float for this column but its storing input that originated as
63.37 and converting it to 63.369999.

thanks for any help on this
rik

**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...

Author
15 Jul 2005 2:52 PM
Aaron Bertrand [SQL Server MVP]
> hey guys, need a little advice here. if i want to restrict a column to a
> decimal precision of 2 - can i do this when i create the table.

CREATE TABLE dbo.TableName
(
    ColumnName DECIMAL(12, 2)
)

> and should i use a decimal or float datatype.

DECIMAL.  FLOAT is for approximate values and will usually lead to rounding
issues unless it provides specific functionality for your app that DECIMAL
can't provide.  For currency or other low-decimal numbers, it is rarely an
appropriate choice.

A
Author
15 Jul 2005 2:57 PM
rbutch@coair.com
excellent. thanks for such a quick answer.

rik

**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...

AddThis Social Bookmark Button