Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Decimals

Author  Topic 

anil1357
Starting Member

1 Post

Posted - 2008-12-10 : 05:49:21
I would like to know how to insert more than 8 decimals after point(.)

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2008-12-10 : 06:01:11
[code]select convert(numeric(10,8),1)
select convert(decimal(10,8),1)[/code]

decimal[(p[, s])] and numeric[(p[, s])]

p (precision)

Specifies the maximum total number of decimal digits that can be stored, both to the left and to the right of the decimal point. The precision must be a value from 1 through the maximum precision. The maximum precision is 38.

s (scale)

Specifies the maximum number of decimal digits that can be stored to the right of the decimal point. Scale must be a value from 0 through p. The default scale is 0; therefore, 0 <= s <= p. Maximum storage sizes vary, based on the precision.

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-10 : 09:15:34
quote:
Originally posted by sakets_2000

select convert(numeric(10,8),1)
select convert(decimal(10,8),1)


decimal[(p[, s])] and numeric[(p[, s])]

p (precision)

Specifies the maximum total number of decimal digits that can be stored, both to the left and to the right of the decimal point. The precision must be a value from 1 through the maximum precision. The maximum precision is 38.

s (scale)

Specifies the maximum number of decimal digits that can be stored to the right of the decimal point. Scale must be a value from 0 through p. The default scale is 0; therefore, 0 <= s <= p. Maximum storage sizes vary, based on the precision.




Using 10 as total number of digits will only leave two digits for integral part of value. so its better to use higher precision, something like
decimal(25,8) & Numeric(25,8) just in case OP's data contain values with more than 2 digits in integral part (left of decimal)
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2008-12-10 : 23:32:44
or u can try this statements
SELECT CAST(1 AS NUMERIC(18,8))
SELECT CAST(1 AS DECIMAL(18,8))
Go to Top of Page
   

- Advertisement -