THE SQL Server Blog Spot on the Web

Welcome to - The SQL Server blog spot on the web Sign in | |
in Search

Denis Gobo

SQL Teaser: Missing FROM

Take a look at this code, will the select return anything or not? Look at the subquery and notice that there is no FROM there.


USE tempdb


CREATE TABLE TestQuery (TestID int)



SELECT * FROM information_schema.columns

WHERE column_name =( SELECT column_name

WHERE column_name = 'TestID')

Published Friday, January 9, 2009 2:30 PM by Denis Gobo
Filed under:



Tim said:


January 9, 2009 2:30 PM

Adam Machanic said:

January 9, 2009 2:59 PM

Aaron Alton said:

That looks familliar, Denis.  It does make you do a double-take, doesn't it? ;)

January 9, 2009 3:07 PM

Denis Gobo said:


haha someone put that on connect  :-) Next up  = NULL doesn't return any NULLs

Itzik Ben-Gan had a variation on this in SQL Mag 2 years (or 3) ago as a puzzle

I also made a post about it here a while back

January 9, 2009 3:08 PM

Denis Gobo said:

Aaron, I got bit by this a while back, since then I always use EXISTS or test the subquery first

January 9, 2009 3:10 PM

Alexander Kuznetsov said:

January 9, 2009 3:11 PM

Adam Machanic said:

Aaron: I just commented on your CTE Connect item...

January 9, 2009 3:22 PM

Adam Machanic said:

Actually, Denis and Alex, you might both be interested in this one as well:

January 9, 2009 3:25 PM

Aaron Alton said:


Thanks for commenting - I responded on Connect as well, with some further discussion.

Being as you seem to have a second residence at Connect... ;)

Is there any way to "sign up for alerts" on your connect items?

January 9, 2009 4:05 PM

Adam Machanic said:


Not that I know of.  There are watchlists and I use them pretty heavily, but that's about it.  Connect is frustrating in lots of different ways... Just wait until your item gets closed as "Fixed" even though it's not :(

January 10, 2009 10:31 AM

AaronBertrand said:

Or "Won't Fix" with no explanation.  Or the worst is "By Design" with no explanation.

January 10, 2009 3:04 PM

Aaron Alton said:

@Adam - already got one of those....a very minor issue, but it's annoying nontheless.  I'd much rather "won't fix" than "fixed", when it's not.  At least I don't feel like I'm on the wrong side of the rabbit hole that way.  

@Aaron - I guess that the only appropriate response would be to keep changing it back to "active" with no explanation ;)

January 10, 2009 8:21 PM

AaronBertrand said:

I tried that on a couple, and it seems that once they are in the "won't respond" state, there is some kind of trigger that sets their state back to closed.  Both times, within minutes, they were closed again.

January 11, 2009 5:18 PM

Aaron Alton said:

I think that you must have had a trigger-happy respondent who happened to be online at the same time.  I set this (very inconsequential) one back to "Active" on the 5th, and it's still "Active":

Granted,there's no response, but at least it's active!

January 11, 2009 6:32 PM
New Comments to this post are disabled

About Denis Gobo

I was born in Croatia in 1970, when I was one I moved to Amsterdam (and yes Ajax is THE team in Holland) and finally in 1993 I came to the US. I have lived in New York City for a bunch of years and currently live in Princeton, New Jersey with my wife and 3 kids. I work for Dow Jones as a Database architect in the indexes department, one drawback: since our data goes back all the way to May 1896 I cannot use smalldates ;-( I have been working with SQL server since version 6.5 and compared to all the other bloggers here I am a n00b. Some of you might know me from or even from some of the newsgroups where I go by the name Denis the SQL Menace If you are a Tek-Tips user then you might know me by the name SQLDenis, I am one of the guys answering SQL Questions in the SQL Programming forum.

This Blog


Privacy Statement