May 20, 2009 at 7:01 am
Hi,
I have a requirement to round off numeric value and its like
@MinValue = 0.8230
@MaxValue = 100.8811
If @DecimalPlaces = 0
The actual saved value for Min Value should be 0.0000 and Max Value should be 100.0000
If @DecimalPlaces = 1
The actual saved value for Min Value should be 0.8000 and Max Value should be 100.8000
If @DecimalPlaces = 2
The actual saved value for Min Value should be 0.8200 and Max Value should be 100.8800
Can we do it using any function of TSQL or using any simple query.
Thanks in advance
May 20, 2009 at 7:27 am
Use ROUND
declare @MinValue decimal(10,5)
declare @MaxValue decimal(10,5)
declare @DecimalPlaces int
set @MinValue = 0.8230
set @MaxValue = 100.8811
--set @DecimalPlaces = 0
--set @DecimalPlaces = 1
set @DecimalPlaces = 2
select round(@MinValue,@DecimalPlaces,1)
select round(@MaxValue,@DecimalPlaces,1)
____________________________________________________
Deja View - The strange feeling that somewhere, sometime you've optimised this query before
How to get the best help on a forum
http://www.sqlservercentral.com/articles/Best+Practices/61537May 20, 2009 at 8:07 am
Best place to start, lookup functions in BOL (Books on-Line).
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply