Finding SELECT Commands in .aspx Files

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"
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: