Pages

Monday, June 2, 2014

TSQL dummy where clause

This is common when a query is being built programatically, so for every condition you will add:
 AND (SOMECONDITION)
so the 1=1 starts the WHERE section, it is always true, and it doesn't hurt the performance.

1=1 is usually used at the top of the where clause for formatting reasons and for ease of debugging. It is correct syntax and has no bearing on the output of the actual query.

No comments:

Post a Comment