Oh and I forgot, you can write positive queries for negative results.

ie   select * from address where city <> 'New York'   -- Never use this
form.

consider
*
 1.   select * from address where not addressId in (select addressId from
address where city = 'New York')*

 *2.   select * from address where isnull(city,'') <> 'New York'   *


If the City field isn't index the 2nd  query comes out best,

If city field is indexed, then the 1st query is better.  If you forget to
index the field Sql Server Management Studio will even suggest the index.


Davy,

The US Congress voted Pizza sauce a vegetable. Don't even try to convince
me of anything in the states is sane any more!



On Thu, Jan 19, 2012 at 12:31 PM, Wallace Turner <wallacetur...@gmail.com>wrote:

>  thanks for that detailed response, very interesting. for the record the
> SP was not that short, it was something more complex buried deep within the
> stored proc.
>
>
> >Isnull + coalesce in queries when you have to, but I try to write only
> positive queries, or queries against non null fields.
>
> Good advice, thanks again.
>
>

Reply via email to