Earlier I asked a puzzle SQL SERVER – Puzzle – Why Decimal is Rounded Up? and it was very well received by all of you. You can read various comments posted in the blog post and they are indeed very enlightening. After posting that blog post, I received quite a lots of emails asking for more puzzle similar to that. Based on your request, here is another puzzle which is very similar to the earlier puzzle but have a very different approach.
The question is why following T-SQL gives a famous divide by zero error.
SELECT 10000/(17/17/17) AS Result2;
When we execute above query it gives following error:
Msg 8134, Level 16, State 1, Line 1 Divide by zero error encountered.
Here is the screenshot of the error.
Hint: Read the comments in this blog post.
I will be announcing the winner of this puzzle in my newsletter. There will be a surprise gift of USD 29. Leave your answers in the comment.
Reference: Pinal Dave (https://blog.sqlauthority.com)