Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.databases.ms-sqlserver    |    Notorious Rube Goldberg contraption    |    19,505 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 17,965 of 19,505    |
|    Hugo Kornelis to Andrew Morton    |
|    Re: Common Table Expression slow    |
|    21 Oct 10 17:26:21    |
      From: hugo@perFact.REMOVETHIS.info.INVALID              On Thu, 21 Oct 2010 09:18:02 +0100, Andrew Morton wrote:              >Hugo Kornelis wrote:       >> On Tue, 19 Oct 2010 16:25:25 -0700, tshad wrote:       >>       >>>       >>> "Andrew Morton" wrote       >>>> tshad wrote:       >>>>> WHERE (@Status = 'ALL') OR ((@Status <> 'ALL') AND (dStart =       >>>>> (Select ...       >>>>       >>>> Unless my brain deceives me at this early hour,       >>>> A OR (NOT A AND B) is the same as A OR B.       >       >Umm... would I be wrong if @Status was NULL?              Yes, you would. If @Status is NULL, both @Status = 'ALL' and @Status <>       'ALL' evaluate to Unknown.       Unknown AND (dStart = ....) evaluates to either False or Unknown       (depends on the result of the second condition       Unknown OR (Unknown or False) evaluates to Unknown.              And since Unknown means the row is rejected, nothing will ever be       returned from this query when @Status is NULL.              I can't believe I overlooked that. :(              --       Hugo Kornelis, SQL Server MVP       My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca