Are we in all these cities?

  • Comments posted to this topic are about the item Are we in all these cities?

  • IMHO, this question does not really illustrate "the point that a subquery cannot be terminated with a semicolon". Semicolons terminate the statements and since the subquery is not the whole statement, it is rather obvious that it cannot be terminated. This question rather falls into a nasty category of those questions where the readers are suggested to use, as Hugo once aptly put it, "psychic powers" to figure out whether the author of the question meant to introduce a simple syntax error or such error is simply a result of an oversight.

    Oleg

  • I got wrong.Because i did not observe the semicolon.

    Malleswarareddy
    I.T.Analyst
    MCITP(70-451)

  • I got it wrong too. I was looking at the logic of the query and the subquery, not at all the fine punctuation details.

    Learned nothing from this question. This is the kind of error (typo) that people make now and then - and then the error message will quickly help you figure out what's wrong.

    I don't mind questions about errors commonly made in T-SQL, or about errors that are hard to figure out due to how the parser presents the error. But I have never seen anyone use a semicolon in a subquery. And if someone does use it, the error message is clear: "Incorrect syntax near ';'." - and if you double-click the error message, you are taken to the line with the offending semicolon.

    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.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • This was removed by the editor as SPAM

  • Sorry, but I think this only checks if you've read the question properly.

    I think everbody KNOWS you don't put a semi colon in the middle of a query (no matter how many people get the question wrong).

  • I got it wrong because I overlooked the semicolon.

    I was focusing more on the use of subqueries with count in a query, which I thought was the point of this question.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Interesting!! victim was ;..........

  • Lousy question, if you ask me ....

    It encourages us to copy and paste the question into the query editor in order to avoid little misreadings. I don't think this is the appropriate way to answer questions which are supposed to teach us something.

    I don't have AdventureWorks installed on any instance, so, after concluding that it should be "return all records" I tried a similar query on our own contacts table, typing the statement manually and (of course!) not making such a mistake!


    If you cant do things the way they must be done, do them the way you can ...

  • Well, got it wrong to. Not that it matters, but this is more a "proofreading" question than anything else. I haven't submitted any QOD myself, so i shouldn't complain...

    But did it anyway 😉

    Lars Broberg
    Elbe-Data AB

  • I saw the semicolon, said "well that looks wrong," and then proceeded to ignore it completely and got the answer wrong. Shows how smart I am.

    -----
    a haiku...

    NULL is not zero
    NULL is not an empty string
    NULL is the unknown

  • 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."

    I've only used semi-colons for multiple short statements on a single line. I've never heard any pros or cons regarding using them or not using them.

    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
  • Tom Garth (7/13/2010)


    I've only used semi-colons for multiple short statements on a single line. I've never heard any pros or cons regarding using them or not using them.

    As I understand it, MS considers their use to be "best practice" but the only times I'm aware of actually needing them is the case you mentioned, and any time you use a CTE -- you have to end any preceding statement with a semicolon.

    ron

    -----
    a haiku...

    NULL is not zero
    NULL is not an empty string
    NULL is the unknown

  • ...and the point is...?

    Not a test of anything as far as I can see. If I add unwanted punctuation my mistake I get an error and remove it, I'm not going to learn anything from that other than that my fingers are too big for my keyboard.

    As most others, I was looking at the logic of the question, not the quality of typing (and plenty of QotDs have had typos - we all know to look past them!).

  • 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?

    I've only used semi-colons for multiple short statements on a single line. I've never heard any pros or cons regarding using them or not using them.

    They are already required before some new language constructions (like WITH). But Microsoft has also announced that the optionality of the semicolon seperator will disappear in a future version. So in a few years time, it will be mandatory to terminate EVERY statement with a semicolon. (Like almost all other computer languages).


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

Viewing 15 posts - 1 through 15 (of 52 total)

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