How does SQL Server determine precision / scale?
8
votes
5
answers
16141
views
I'm running SQL Server 2012
SELECT
0.15 * 30 / 360,
0.15 / 360 * 30
Results:
0.012500,
0.012480
This one is even mor confusing to me:
DECLARE @N INT = 360
DECLARE @I DECIMAL(38,26) = 0.15 * 30 / 360
DECLARE @C DECIMAL(38,26) = 1000000
SELECT @C * @I * POWER(1 + @I, @N) / ( POWER(1 + @I, @N) - 1 )
SELECT @C * (@I * POWER(1 + @I, @N) / ( POWER(1 + @I, @N) - 1 ) )
The first select gives me the correct result: 12644.44022
The second one truncates the result: 12644.00000
Asked by cpacheco
(83 rep)
Sep 25, 2014, 06:44 PM
Last activity: Sep 3, 2020, 09:36 AM
Last activity: Sep 3, 2020, 09:36 AM