ORDER BY nella clausola UNION in SQL Server 2000 e 2005 (o successivi)

Sergio Govoni

Con SQL Server 2000, vi siete mai imbattuti nel messaggio di errore numero 104 ?

Server: Msg 104, Level 15, State 1, Line 1
ORDER BY items must appear in the select list if the statement contains a UNION operator.

Questo messaggio viene restituito quando si utilizza l’operatore UNION per combinare i risultati di due o più istruzioni SELECT nelle cui dichiarazioni è presente una clausola ORDER BY e le colonne citate nell’ordinamento non sono parte (anche) della SELECT.