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.
Author |
Topic |
sent_sara
Constraint Violating Yak Guru
377 Posts |
Posted - 2013-12-13 : 23:00:07
|
Declare @hardcurrency Table(Rate numeric(28,4))insert @hardcurrencyselect 25000.0000union allselect 3.0825union allselect 950000.0000select rate,round(1/rate,4) as ExRatefrom @hardcurrency whenever im rounding to 4 its coming as:0.000000000000000000000000000000.324400000000000000000000000000.00000000000000000000000000000Expected output should be :ExRate0.000040.32440.000001if i got the scale value which is > 0 from the beginning itself mean then round off to 4 else until i get the number(>0) i need to round off there. |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2013-12-13 : 23:46:48
|
quote: if i got the scale value which is > 0 from the beginning itself mean then round off to 4 else until i get the number(>0) i need to round off there.
what do you mean by that ? KH[spoiler]Time is always against us[/spoiler] |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-12-14 : 07:33:53
|
you cant have variable scale value. You need to set based on available values the scale value you want and all values will be shown rounded based on it------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
sent_sara
Constraint Violating Yak Guru
377 Posts |
Posted - 2013-12-14 : 17:34:01
|
can u please give some example for this?quote: Originally posted by visakh16 you cant have variable scale value. You need to set based on available values the scale value you want and all values will be shown rounded based on it------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs
|
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2013-12-15 : 08:58:35
|
[code]case when round(1/rate,4) <> 0 then convert(numeric(28,10), round(1/rate,4)) else convert(numeric(28,10), left(convert(varchar(max), 1/rate), patindex('%[1-9]%', convert(varchar(max), 1/rate)))) end[/code] KH[spoiler]Time is always against us[/spoiler] |
|
|
|
|
|
|
|