November 18, 2008 at 9:00 am
Hi
I want to set my database property to return a decimal number when I do division .
e'g select 1/10 should return 0.1 instead of 0
how do I set this property? Please help
November 18, 2008 at 9:06 am
well it depends what data types you working with.
SELECT 1/10 will always return 0 as 1 and 10 are both INT.
If they where decimals then they would return .something for example.
SELECT 1/CAST(10 as DECIMAL(10,2))
----------------------------------------------
Try to learn something about everything and everything about something. - Thomas Henry Huxley
:w00t:
Posting Best Practices[/url]
Numbers / Tally Tables[/url]
November 18, 2008 at 9:08 am
sello Moloto (11/18/2008)
HiI want to set my database property to return a decimal number when I do division .
e'g select 1/10 should return 0.1 instead of 0
how do I set this property? Please help
I think this should be easily looked up on the Books Online or anywhere else, but ok.
NUMERIC(13,1)
The 13 represents how many digits you want to be able to present, the 1 is the number of decimal digits.
Ronald HensbergenHelp us, help yourself... Post data so we can read and use it: http://www.sqlservercentral.com/articles/Best+Practices/61537/-------------------------------------------------------------------------2+2=5 for significant large values of 2
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply