Re: WHERE 1=2 with performance nightmares



SQL server definitely will optimize and return no recs and no errors. I have
been using that technique for years. i have heard that it is flaky on Oracle
but not sure. Randomizing doesn't solve the problem because most of the time
we do this to get an "initialized" empty recordset which we can append
records into.

You can sometimes do select * from mytable where id = -1 and that will
work if "id" is a unique key (or primary which every good DB should have)
and the DB engine will check the PK index and return zero records, no
errors.
Randomizing *might* return 1 record, which is not good if you are trying to
update databases in batchoptimistic mode.


.