Programming in MS SQL Server 2012

Decimal Data Type



Decimal data type is used to stores floating-point number or Fractional Number. Decimal and Float variable must define with precision and scale. The following statements are used to define different types of variables in SQL Server. The following example describes a Decimal Data Type.

-- Example 75 --

 

DECLARE @ProductRate01 Decimal (5,2)

SET @ProductRate01 = 123.45

SELECT @ProductRate01 AS [Product Rate]

 

DECLARE @ProductRate02 Numeric (5,2)

SET @ProductRate02 = 123.45

SELECT @ProductRate02 AS [Product Rate]


Query Output Screen



Note:

If decimal data type Precision 1 - 9 then, SQL Server defines 5 bytes memory

If decimal data type Precision 10 - 19 then, SQL Server defines 9 bytes memory

If decimal data type Precision 20 - 28 then, SQL Server defines 13 bytes memory

If decimal data type Precision 29 - 38 then, SQL Server defines 17 bytes memory

* * * * *


Email Your Comment To AUTHOR