SQL SERVER – Two Puzzles – Answer and Win USD 25 Gift Card

Posted by pinaldave on SQL Authority See other posts from SQL Authority or by pinaldave
Published on Thu, 30 Jun 2011 01:30:06 +0000 Indexed on 2011/06/30 8:25 UTC
Read the original article Hit count: 459

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
SELECT @x;

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
SELECT @y;

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

  1. To win the Gift Card USD 25 you will have to answer both of the question on my Facebook page.
  2. 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.

Related Post: SQLAuthority News – Monthly list of Puzzles and Solutions on SQLAuthority.com

Reference: Pinal Dave (http://blog.SQLAuthority.com)


Filed under: Pinal Dave, PostADay, SQL, SQL Authority, SQL Puzzle, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, SQLServer, T SQL, Technology

© SQL Authority or respective owner

Related posts about Pinal Dave

Related posts about PostADay