During tests of my most recent versions of dbscript I ran into problems with a SELECT statement that works fine on SQL Server 2000, but raises an error on SQL Server 2005.
The statement is in the form of
SELECT NULL AS OID, NULL AS ID UNION ALL SELECT MyTable.OID, MyTable.ID FROM MyTable ORDER BY MyTable.ID
The statement retrieves all records of MyTable, and adds an empty record at the beginning. The problem seems to be that while SQL2000 only considers the column name of the ORDER BY clause, SQL2005 cannot find the column MyTable.ID in the result set, as it is only defined as ID in the first SELECT.
After fixing the statement, the obvious question was where else in the source code such statements occurred.
A single line on the cmd prompt invoking my graspx tool showed the occurrences:
graspx l SelectCommand *.aspx | find "UNION" | find "ORDER"