The Formula Is:
2 ^ (N-1)
" is nothing but size of the Data type."^
" means Power of the value.
1. We just want to get the Maximum length of the Data type "INT".
Select (max_length * 8) 'Bit(s)' from sys.types Where [name] = 'Int'
The answer is : 32 Bit(s)
2. Now, we can apply the formula for Range
Select Power(Cast(2 as Varchar),(max_length * 8) -1) from sys.types Where [name] = 'Int'
The Result is : 2147483648
The maximum range of "INT" data type is -2147483648 to 2147483647
Asked In: Many Interviews |