decimal(15,4) : decimal « Data Type « SQL Server / T-SQL






decimal(15,4)


15>
16> SET NOCOUNT ON
17> DECLARE @float1 float, @float2 float, @float3 float, @float4 float
18> DECLARE @dec1 decimal(15,4), @dec2 decimal(15,4),
19>         @dec3 decimal(15,4), @dec4 decimal(15,4)
20> DECLARE @pointseven decimal(15,4)
21> SET @float1 = 7
22> SET @float2 = 100
23> SET @float3 = .0009
24> SET @float4 = @float1/@float2 - @float3
25> SET @dec1 = 7
26> SET @dec2 = 100
27> SET @dec3 = .0009
28> SET @dec4 = @dec1/@dec2 - @dec3
29> SET @pointseven = .7
30> SELECT @float4 '@float4', @float3 '@float3',
31>        @pointseven - @float4 'float diff'
32> SELECT @dec4 '@dec4', @dec3 '@dec3',
33>        @pointseven - @dec4 'dec diff'
34>
35> GO
@float4                  @float3                  float diff
------------------------ ------------------------ ------------------------
   6.9100000000000009E-2    8.9999999999999998E-4      0.63089999999999991
@dec4             @dec3             dec diff
----------------- ----------------- ------------------
            .0691             .0009              .6309
1>
           
       








Related examples in the same category

1.Use select to do the calculation
2.Function returning decimal
3.Cast int to decimal
4.Cast real number to decimal
5.Cast decimal to varchar and append another string
6.Average of decimal values