sql server - 'an expression of non boolean type specified' in CASE WHEN -


given t-sql code:

select case           when ( cast (case                          when isnull(bpe.new, 0) = 0                               , isnull(bpe.regular, 0) = 0                               , isnull(bpe.bargain, 0) = 0 0                          else 1                        end bit)                  , @siteid null                   or bpe.siteid = @siteid ) 1           else 0         end sitehasbrandexception    brandpromoexceptions bpe  

i error message:

an expression of non boolean type specified in context condition expected tsql

why that?

if mean 0 "false" first bit, query should equivalent to:

select case when  not ( isnull(bpe.new, 0) = 0        , isnull(bpe.regular, 0) = 0        , isnull(bpe.bargain, 0) = 0 ) , ( @siteid null        or bpe.siteid = @siteid ) 1  else 0  end sitehasbrandexception  brandpromoexceptions bpe  

you may need careful "or" clause, or add parentheses clarification. guessed here.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -