Is there anyway I can use UNION only if it meets my condition? I'm trying to combine table_a and table_b (only if it meets my condition). Here's what I'm trying to do but it doesn't work.
declare @type varchar(10)
set @type = 'all' -- the value is either 'all' or null
select * from table_a
if @type = 'all' -- if 'all' then do union else no need
union all select * from table_b
please help!
Maingel
Andel
maingel@hotmail.com
declare @type varchar(10)
set @type = 'all' -- the value is either 'all' or null
select * from table_a
if @type = 'all' -- if 'all' then do union else no need
union all select * from table_b
please help!
Maingel
Andel
maingel@hotmail.com