Today I have two simple T-SQL Puzzle. You can answer them and win USD 25 Gift card. The gift card will be sent in email to winner. You will get choice of Gift Card brand based on your preference and country location.
Puzzle 1: What will be the outcome and why?
DECLARE @x REAL;
SET @x = 9E-40
The outcome here is obvious as I have used negative number in assignment. What is the reason behind the same?
Puzzle 2: Why will be the outcome different from Puzzle 1:
DECLARE @y REAL;
SET @y = 9E+40
The outcome of this puzzle very different from puzzle 1 as I have used positive number. There is number six (6) in the resultset why?
Msg 232, Level 16, State 2, Line 2
Arithmetic overflow error for type real, value = 90000000000000006000000000000000000000000.000000.
How to participate
- To win the Gift Card USD 25 you will have to answer both of the question on my Facebook page.
- If you are on twitter – you can increase the chance of winning by tweeting your participation.
This contest is open for any one from any country. The winner will be selected Randomly. Winner will be announced on July 7, 2011.
Reference: Pinal Dave (https://blog.sqlauthority.com)