I am trying to union two result sets and omit the results from the first set when returning the second unioned set.
However, when the second set is selected it is appending the data from the sub-query.
declare @bool nvarchar(1) = 'Y'
select [name[
from table_1
where @bool = 'N'
union
select [name]
from table_2 t2
where @bool = 'Y'
and [name] not in (
select [name]
from table_1
)
How can I select the second part when @bool = 'Y'
without the not in
sub-query appending its results to the dataset?