Are we in all these cities?

  • Hugo Kornelis (7/13/2010)


    Tom Garth (7/13/2010)


    I got it right for the wrong reason. I didn't notice the semi-colon, and since A. would not have been a complete answer, I chose C. which amounted to "None of the above."

    Why do you think A would not have been a complete answer?

    It's just me Hugo. I felt that in the context of the question without the semi-colon issue, the answer provided with A. was lacking. As in - what is the question trying to point out, or what is there to learn from this. That's all.

    Tom Garth
    Vertical Solutions[/url]

    "There are three kinds of men. The one that learns by reading. The few who learn by observation. The rest of them have to pee on the electric fence for themselves." -- Will Rogers
  • Trick question! We shouldn't be testing syntax. What a waste of time!

    :angry:

  • I was completely stumped by the answer choices. Like everyone else I missed the semicolon in the subquery and was focused on trying to figure out which of the other answers would be close enough to get it right. The closest "correct" answer was A but it left off the count.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • Add me to that boat. I didn't even see the semi-colons... I've trained myself to ignore them when they aren't required... and since we didn't need one at all for that statement... I missed it. :/

    Spent too much time looking at the logic of the query... not fxing stpd typ0s 😛



    --Mark Tassin
    MCITP - SQL Server DBA
    Proud member of the Anti-RBAR alliance.
    For help with Performance click this link[/url]
    For tips on how to post your problems[/url]

  • Well, there had been many instances when the QOD query was wrong and it was corrected later. I thought so and ignored " ; " in syntax in sub query.

    SQL DBA.

  • Hugo Kornelis (7/13/2010)


    ...

    I hope the author will stop by and tell us what he/she was trying to teach us with this question. Maybe I missed the deeper issue here.

    I actually derived the question from a mistake I made working on a stored procedure. Appearenly, SQL Server will eventually require the use of properly placed semi-colons. So, sooner or later, we will all have to learn how to use them correctly.

    This was my first attempt at a QoD so my appologies if it was not up to par. I look forward to submitting more as I come accross various SQL puzzles in my daily work activities.

    Best regards,

    Dave

  • I missed it too - I took a guess at what the question was trying to test and thinking it was something else missed the question. Oh well. I am grateful Dave that you took the time to write up a QOD so that I have something to look forward to every day. Keep it up and write another!

    Thanks,

    Chad

  • I missed the semicolon in the subquery. To that extent, this question taught me to look for those. It's in my passive SQL vocabulary, so to speak - I (unfortunately) don't walk around feeling like it is obvious that a semicolon can't be in a subquery or elsewhere in the middle of a statement. At the same time, I have never put a semicolon in such places because somewhere in the back of my mind I had the knowledge that it is a termination character and so shouldn't appear earlier than the end of the statement. So I think that part of the question was worth it for me because I realized that this is something I should be able to articulate clearly when I see it in code. And so I thank the question poster for the effort.

    But unfortunately the question relies on the same kind of trick question format we've seen in the past. I think the question is 75% proofreading and 25% T-SQL. I don't know how to add the necessary element of misdirection or close-but-wrong answers without this kind of trick, but I always find it unsatisfying when I see it. I can't nitpick because the question is based on something technically correct... but there is still a nagging doubt about the pedagogical value of the particular trick used.** Believe it or not, because of this I almost picked the answer "An error message" thinking perhaps the Northwind database wasn't in SQL 2008 SP1. Once I started down that path, I felt like I was facing a trick question, although the trick was different from the one I guessed.

    - webrunner

    ** See for example, "In a year, some months have 30 days, while some have 31. Guess, which month has 28 days?"

    http://www.buzzle.com/articles/trick-questions-and-answers.html

    -------------------
    A SQL query walks into a bar and sees two tables. He walks up to them and asks, "Can I join you?"
    Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html

  • Dave62 (7/13/2010)


    Hugo Kornelis (7/13/2010)


    ...

    I hope the author will stop by and tell us what he/she was trying to teach us with this question. Maybe I missed the deeper issue here.

    I actually derived the question from a mistake I made working on a stored procedure. Appearenly, SQL Server will eventually require the use of properly placed semi-colons. So, sooner or later, we will all have to learn how to use them correctly.

    This was my first attempt at a QoD so my appologies if it was not up to par. I look forward to submitting more as I come accross various SQL puzzles in my daily work activities.

    Best regards,

    Dave

    Keep trying Dave. Having something about semicolons in the title would have caused more of us to focus on the semicolon. I agree with your statement about having to learn how to use them so you make a very good point.

  • I tend to dislike "syntax error" questions since they are usually easily corrected. Double click the error, find the line, examine it.

    However there are lots of people that don't seem to find syntax errors and post questions in the forums. I let this go as a good reminder.

  • Thanks for the question. I learned something. I didn't know that Not ending Transact-SQL statements with a semicolon was on the Deprecated Database Engine Features in SQL Server 2008 R2.

    http://msdn.microsoft.com/en-us/library/ms143729.aspx

    Thanks,

    Kevin

  • Interesting question, however, the part that I thought was incredible was that the questions was a 2 pointer, and for obvious reasons. It stumped many of the more experienced propeller heads.

  • I must admit that when I first answered and got it wrong, I was very annoyed that it was a syntax question since, from the context, I didn't think that was what was being asked.

    But then, after reading many of the comments (especially Webrunner's and the author's), I realized that I, too, did not recognize immediately that you could not put a terminating mark there. Like Webrunner, had I thought about it I believe I would have been able to figure it out, but it didn't jump out at me as being wrong.

    And as others have pointed out, the use of semicolons will be required as terminating marks in the future (and are already required for some commands), so it's good that we are reminded of their proper use.

    And so, thanks for the question.

  • Can people please start posting these trick questions - SQL Server is a big enough topic that people can find plenty of real questions 😉

  • I got it right because I had to make a binary decision on if the syntax error was meant to be there or not and guessed right. Too many times the QOD has had unintentional syntax errors. Thanks for the Question though, please try again. 🙂

    I do like your point about the semi-colon being required in a future release. I've also begun using the semi-colon.

    ---------------------------------------------------------------------
    Use Full Links:
    KB Article from Microsoft on how to ask a question on a Forum

Viewing 15 posts - 16 through 30 (of 52 total)

You must be logged in to reply to this topic. Login to reply