Steve Jones - SSC Editor wrote:
Thom A wrote:
OH gods, it has a
WHERE 1=1 clause too. ??
This is likely built dynamically, so the 1=1 provides a basis for the query.
But it's easy enough to clean up. Just
REPLACE(REPLACE(@sql, '1=1 AND ', ''), 'WHERE 1=1', ''). So if there are additional conditions, you remove the 1 = 1 and the following AND, otherwise you remove the WHERE 1 = 1.
J. Drew Allen
Business Intelligence Analyst