select @sql = '
insert into #actids
select act_id from (
select act_id = 1 union select 2) x
where 1 = 1
' + isnull(@actvisitfilter, '') + '
union select act_id from (
select act_id = 1 union select 2) x
where 1 = 1
' + isnull(@actnonvisitfilter, '') + '
union select act_id from (
select act_id = 1 union select 2) x
where 1 = 1
' + isnull(@actotherpayfilter, '')
exec (@sql)