May 28, 2010 at 7:12 am
They may all work, but they are all a crime against readability. I make a point of white space for readability just about everywhere.
May 28, 2010 at 7:17 am
"A crime against readability" I'll reuse that quote soon enough.
May 28, 2010 at 7:25 am
I'm afraid I have to join the chorus in saying the question was poorly worded.
Interesting info though.
May 28, 2010 at 7:33 am
malleswarareddy_m (5/27/2010)
I did not understand this question.in question it shows that to select wrong sytax.but all resturns table data without any error.then i did not found the wrong answer.so i applied three answers.got my point.
He did say "select all that apply"
So 1st you have to select all the statements that are correct, then guess the error statements?
The part about guessing the error messages, if there are any, are for extra credit:-D
Ken
May 28, 2010 at 8:45 am
All are correct
May 28, 2010 at 8:52 am
I have removed the sentence about error messages since it was confusing.
May 28, 2010 at 9:25 am
I'd have liked to see a 4th option, "none of the above". I believe that would have added to the educational opportunity.
But then, why pose this question at all? Doesn't it promote harder to read code, and the memorization of what is essentially trivia?
select * from table_name
I'd argue that the above statement is: easier to read, doesn't require knowledge of this trivia, works if you substitue "my_column" for the "*", and is probably far more cross platform compatible.
These are meant as constructive criticisms. I do very much appreciate the learning opportunity!
May 28, 2010 at 9:48 am
thanks for the Question
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
May 28, 2010 at 10:16 am
In testing out the theory (not pasting from the examples which inherently include a space before the table name)... only the second query runs without error:
--WON'T RUN: select*fromUDM.DimDate --'no space between select, *, and from
select* from UDM.UDM.DimDate -- 'no space between select and *
--WON'T RUN: select *fromUDM.DimDate-- 'no space between * and from
I ran this against 2005 SQL Server via Management Studio.
May 28, 2010 at 10:21 am
Gotcha! The spacing between Select*from doesn't matter but there must be a space after from for the table name.... THanks for the learning!
May 28, 2010 at 10:36 am
I personally didn't find the question confusing. And, although the syntax definitely is NOT advisable for readability, etc. it is interesting to know how SSMS will parse some code without the white space.
Thanks for the question.
May 28, 2010 at 11:51 am
I would argue that while all three compile and run, none of them is "correct." If they were correct, then so would this be, and you know it's not:
SELECTmycolumnFROM MyTable;
SELECTmycolumn FROM MyTable;
SELECT mycolumnFROM MyTable;
However, I'd leave the question alone. It was interesting to see weirdness in the parser.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
May 29, 2010 at 6:53 am
Grant Fritchey (5/28/2010)
I would argue that while all three compile and run, none of them is "correct."
In the same way that 2+2=5 for sufficiently large values of 2? 😛
May 29, 2010 at 6:53 am
Nice (but quite shocking!) question. I'm not at all embarrassed to say I got this one wrong.
June 1, 2010 at 7:49 am
For me all three options worked. I am using SQL 2008 express edition .
Viewing 15 posts - 16 through 30 (of 37 total)
You must be logged in to reply to this topic. Login to reply