Replace derived table wrapping with direct TOP injection for SQL Server to prevent error 8155 when inner SELECT produces unnamed columns (e.g. SELECT @@version). Also preserves ORDER BY that was incorrectly stripped by the previous approach.
Replace derived table wrapping with direct TOP injection for SQL Server to prevent error 8155 when inner SELECT produces unnamed columns (e.g. SELECT @@version). Also preserves ORDER BY that was incorrectly stripped by the previous approach.