Find the Cause of Query Malfunctions

Find the Cause of Query Malfunctions

This tip is for SQL Server 6.5 and up. When debugging a SELECT query, add an absolute true condition as the first condition of the WHERE clause:

 SELECT	au_lname,	au_fnameFROM	authorsWHERE	1=1 --absolute true condition	and state = 'CA'	and contract = 1

That way, you can comment out one or more of the real conditions in the WHERE clause using the “- -” comment character sequence to narrow down which condition(s) cause the query to malfunction. When you


Share the Post: