Below is the table structure:
create table source_a (cid varchar(10), fname varchar(50),record_status int)
create table target_a (cid varchar(10), fname varchar(50),record_status int)
insert into source_a values ('C001', 'Sam',0)
insert into source_a values ('C002', 'Roy',0)
insert into source_a values ('C003', 'Tom',3)
I want record from source with record_status = 0 should be inserted into target. How to do it?
Below query is not working:
merge target_a as target using source_a as source on (target.cid=source.cid ) when matched then update set target.fname = source.fname, target.record_status = source.record_status when not matched by target then insert (cid,fname,record_status) values (source.cid,source.fname,source.record_status);
Thanks in advance