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 IN QUERY

Author  Topic 

annamaria
Starting Member

30 Posts

Posted - 2007-05-31 : 04:28:39
review

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-05-31 : 04:34:41
SELECT CAST(Field1 AS DECIMAL(21, 16)) / CAST(Field2 AS DECIMAL(21, 16))


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-05-31 : 04:49:27
You should not. Are you using the result in a front-end application?
Check application and/or data layer parameters.
DECLARE	@num1 DECIMAL(14, 5),
@num2 DECIMAL(14, 5)

SELECT @num1 = 31.45,
@num2 = 2.67

SELECT CAST(@num1 AS DECIMAL(21, 16)) / CAST(@num2 AS DECIMAL(21, 16))


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-05-31 : 04:50:02
The result from the query/code above is in SSMS

11.77902621722846441

Peter Larsson
Helsingborg, Sweden
Go to Top of Page

Jeff Moden
Aged Yak Warrior

652 Posts

Posted - 2007-05-31 : 21:06:45
The OP post "dec" for "decimal"... probably not using SQL Server...

--Jeff Moden
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-05-31 : 23:40:31
quote:
Originally posted by Jeff Moden

The OP post "dec" for "decimal"... probably not using SQL Server...

--Jeff Moden


Yes. see http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=84146
quote:
I use SQL for DB2



KH

Go to Top of Page
   

- Advertisement -