sql server 2008 - IF statement with Transact SQL -


when execute transact sql code

if (select model_id request_unit request_id = '4357') null     select part_id request_unit request_id = '4357' else      select model_id request_unit request_id = '4357' 

i receive following error:

subquery returned more 1 value. not permitted when subquery follows =, !=, <, <= , >, >= or when subquery used expression.

how using coalesce()?

select coalesce(model_id, part_id) request_unit  request_id = '4357'; 

the if not needed.

the error seems pretty self-explanatory. there more 1 row in request_unit request_id 4357.


Comments