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