if object_id('[ta]')is not null
drop table ta
create table ta
(
acode varchar(20),
selected varchar(20)
)
insert into ta(acode,selected)
select '111',''
union all
select '222',''
union all
select '333',''
if object_id('[tb]')is not null
drop table tb
create table tb
(
bcode varchar(20)
)
insert into tb(bcode)
select '111'
union all
select '222'
select acode,case when acode=bcode then 'true'
else 'false' end as flag
from ta left join tb
on ta.acode=tb.bcode
if object_id('[ta]')is not null
drop table ta
create table ta
(
acode varchar(20),
selected varchar(20)
)
insert into ta(acode,selected)
select '111',''
union all
select '222',''
union all
select '333',''
if object_id('[tb]')is not null
drop table tb
create table tb
(
bcode varchar(20)
)
insert into tb(bcode)
select '111'
union all
select '222'
select acode,case when acode=bcode then 'true'
else 'false' end as flag
from ta left join tb
on ta.acode=tb.bcode