The following SQL snippet shows errors in SSMS.
The italics are the underlining from SSMS.
The code runs fine without error.
What is going on?
SELECT
ry.*
FROM (
SELECT
MAX(ry0.ReportingYear) ReportingYear
FROM (
VALUES
(1, 'AAA', 'BBB')
, (2, 'AAA', 'BBB')
, (3, 'AAA', 'BBB')
, (4, 'AAA', 'BBB')
, (5, 'AAA', 'BBB')
) ry0 ( ID, ReportingYear, Filler1 )
) ry ( ReportingYear )
Severity Code Description Project File Line
Error The multi-part identifier "ry0.ReportingYear" could not be bound. test2106 SQLQuery37.sql 12
Error The column prefix 'ry' does not match with a table name or alias name used in the query. test2106 SQLQuery37.sql 9
Error Incorrect syntax near ''. Expecting ')', or ','. test2106 SQLQuery37.sql 16
Error Incorrect syntax near 'ReportingYear'. Expecting '(', or SELECT. test2106 SQLQuery37.sql 21
Error Incorrect syntax near 'ID'. Expecting '(', or SELECT. test2106 SQLQuery37.sql 20
Error Incorrect syntax near '5'. test2106 SQLQuery37.sql 19
Error Incorrect syntax near '4'. test2106 SQLQuery37.sql 18
Error Incorrect syntax near '3'. test2106 SQLQuery37.sql 17
Error Incorrect syntax near ','. Expecting AS, ID, or QUOTED_ID. test2106 SQLQuery37.sql 18
Error Incorrect syntax near ''BBB''. test2106 SQLQuery37.sql 17
Error Incorrect syntax near ''BBB''. test2106 SQLQuery37.sql 18
Error Incorrect syntax near ''BBB''. test2106 SQLQuery37.sql 19
Error Incorrect syntax near ''AAA''. test2106 SQLQuery37.sql 17
Error Incorrect syntax near ''AAA''. test2106 SQLQuery37.sql 18
Error Incorrect syntax near ''AAA''. test2106 SQLQuery37.sql 19
Microsoft SQL Server Management Studio 14.0.17289.0
Microsoft Analysis Services Client Tools 14.0.1016.283
Microsoft Data Access Components (MDAC) 6.3.9600.17415
Microsoft MSXML 3.0 6.0
Microsoft Internet Explorer 9.11.9600.19963
Microsoft .NET Framework 4.0.30319.42000
Operating System 6.3.9600
