SQL as well as database design is what gives the likes of ColdFusion and all middle tier app. server solutions a bad name. I have seen lines and lines of SQL code kluge and clog up applications. This leaves dba and developers pointing fingers and makes for a frustrating experience. What happens in this case is a developer will use ColdFusion as the scapegoat or opt to move for a hardware upgrade... UGGG! Many of these issues can be cleared up with a very simple change and some simple concepts that the programmer didn't realize was available.
Some of these concepts are proper database design and alternative query methods such as sub queries at the field level and in the where clause, forcing nulls when data is not found and handling appropriately with ISNULL or NVL. (Just a brief example of something one might not have thought of).
Here's a good one, how about nesting ISNULL or NVL to handle a null from 2 subqueries that return null in the inner null. It's fast and can be done with one line of code rather than creating multiple cursors to load data to a temp table to ultimately pick out or append records that apply to a specified filter.
Many techniques such as these go undiscovered due to lack of documentation (book or otherwise) and pressing deadlines, which can put a coders head in a bubble. As a coder, when you get that, "there's gotta be an easier, more concise way" feeling... know that there always is and it may be time to take a Google break or thumb through that Rafe Colburn "Using SQL" book you paid 40 bucks for on Amazon.
In all seriousness, there is a wealth of information about SQL and best practices out there. Books are great, but they tend to get outdated. Personally I think that all developers who use SQL Server should visit http://www.sqlservercentral.com/.
It's probably one of the best sites out there for SQL optimiztion information. Also there are TONS of usenet newsgroups out there.
I just recently has to wade through a large 8 page StoredProc to figure out what someone was doing.
Turns out, I just needed a SQL with two inner joins.
I am with you Michael!
http://doc.ddart.net/mssql/sql2000/html/
MS SQL Books Online
That's usually a good starting point..
His where clause had AND POLICY = 'NULL'.
sigh...shaking head.