Use select to do the calculation : decimal « Data Type « SQL Server / T-SQL






Use select to do the calculation


12> SET NOCOUNT ON
13> DECLARE @dec1 decimal(38,0)
14> SET @dec1 = CAST(POWER(10,9) as decimal(38,0))
15> SELECT @dec1 * @dec1 * @dec1 * @dec1 * 10 AS 'Large Decimal value',
16>     FLOOR(LOG10(@dec1 * @dec1 * @dec1 * @dec1 * 10)
17>     + 1) AS 'Number of digits'
18> GO
Large Decimal value                      Number of digits
---------------------------------------- ------------------------
  10000000000000000000000000000000000000                       38
1>
2>
           
       








Related examples in the same category

1.decimal(15,4)
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