SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,361 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello, I have to replace the number in decimal area with Zero if decimal value is less than 0.99
Data:
7889.00008000
7828.00800000
7363.00000060
7363.99999990
Expected output: --All decimals should be Zero except if decimal value is less than 0.99
7889.00000000
7828.00000000
7363.00000000
7363.99999990
Declare @Sample Table(Nbr decimal(15,8));
Insert @Sample(Nbr) Values
(7889.00008000),
(7828.00800000),
(7363.00000060),
(7363.99999990);
Update @Sample
Set Nbr = Floor(Nbr)
Where Floor((Nbr*100)) % 100 <> 99;
Select Nbr From @Sample;
Tom
Did you try to CAST the numeric to decimal?
DECLARE @n numeric = 7363.00000060;
SELECT CAST(@n AS decimal(20, 8));