August 2, 2011 at 10:42 pm
Good question, but try:
SELECT 'Test' WHERE EXISTS (SELECT LOG(0))
TSQL is not a model of consistency.
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
August 2, 2011 at 10:59 pm
Good Question thanks 🙂
August 2, 2011 at 11:00 pm
SQLkiwi (8/2/2011)
Good question, but try:
SELECT 'Test' WHERE EXISTS (SELECT LOG(0))
TSQL is not a model of consistency.
Even for the below statement also
SELECT 'Test' WHERE EXISTS (SELECT SQRT(-1))
August 2, 2011 at 11:13 pm
deepak.a (8/2/2011)
Even for the below statement also
SELECT 'Test' WHERE EXISTS (SELECT SQRT(-1))
Some more:
SELECT 'Test' WHERE EXISTS (SELECT ACOS(PI()))
SELECT 'Test' WHERE EXISTS (SELECT ASIN(PI()))
SELECT 'Test' WHERE EXISTS (SELECT LOG10(0))
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
August 3, 2011 at 12:03 am
Thanks for the question
M&M
August 3, 2011 at 12:20 am
Good question
-----------------
Gobikannan
August 3, 2011 at 12:43 am
Interesting question, thanks!
/@devandreas
August 3, 2011 at 1:16 am
I didn't like the "explanation".
What I am missing is the real explanation why the sub query in the EXISTS doesn't result in an error.
It actually matters what is in that sub query. For example:
SELECT 'Test' WHERE EXISTS (SELECT 1 WHERE 1 = 0)
will not return anything.
August 3, 2011 at 2:21 am
Interesting question, and something definitely to be aware of.
Thanks
_____________________________________________________________________
[font="Comic Sans MS"]"The difficult tasks we do immediately, the impossible takes a little longer"[/font]
August 3, 2011 at 2:44 am
EXISTS check if subquery returns ROWS and does not execute EXPRESSION or read column value. So, in this case divide by zero is never executed, but ONE ROW exists.
August 3, 2011 at 3:08 am
DugyC (8/3/2011)
Interesting question, and something definitely to be aware of.Thanks
I'm not convinved that I need to be aware of this.
Interesting question though.
August 3, 2011 at 3:13 am
paul s-306273 (8/3/2011)
DugyC (8/3/2011)
Interesting question, and something definitely to be aware of.Thanks
I'm not convinved that I need to be aware of this.
Interesting question though.
I agree with you.
August 3, 2011 at 3:14 am
So if Microsoft are correct to claim that this is by design, then presumably they would acknowledge all the counter-examples provided by SQLkiwi as bugs?
P.S. I wonder how many of the 60% who got this right did so without running the code!
August 3, 2011 at 3:44 am
I'm not convinced that EXPRESSION is not executed
Try this:
SELECT 'TEST'
WHERE EXISTS (SELECT 1/0 WHERE 1/0 =1)
Viewing 15 posts - 1 through 15 (of 43 total)
You must be logged in to reply to this topic. Login to reply