Toby Harman - Wednesday, March 13, 2019 10:40 PM
Nice question, thanks Evgeny.
Tony, this is not a bug, but a side effect of correlated subqueries.
all columns from the main SELECT are available for use in the subselect, so it will compile.
per this extract from Microsoft docs:
Important
If a column is referenced in a subquery that does not exist in the table referenced by the subquery's
FROM
clause, but exists in a table referenced by the outer query'sFROM
clause, the query executes without error. SQL Server implicitly qualifies the column in the subquery with the table name in the outer query.
____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”