UPDATE TABLE1 SET tecnicalclassmax='技师'
FROM TABLE1 ,(SELECT workid FROM table2 WHERE tecnicalclass='技师') B
WHERE TABLE1.workid=B.workidINSERT INTO table1
SELECT workid,'技师'
FROM table2 A LEFT JOIN TABLE2 B ON tecnicalclass='技师' AND A.WORKID=B.WORKID
WHERE B.WORID IS NULL
FROM TABLE1 ,(SELECT workid FROM table2 WHERE tecnicalclass='技师') B
WHERE TABLE1.workid=B.workidINSERT INTO table1
SELECT workid,'技师'
FROM table2 A LEFT JOIN TABLE2 B ON tecnicalclass='技师' AND A.WORKID=B.WORKID
WHERE B.WORID IS NULL
for insert,update
as
if exists(updated.tecnicalclass='技师')
begin
if exists( select 1 from table1 where table1.workid=updated.workid )
begin
update table1 set tecnicalclass='技师'where tabl1.workid=updated.workid
end
else
begin
insert into table1 select * from updated
end
end if exists(inserted.tecnicalclass='技师')
begin
if not exists( select 1 from table1 where table1.workid=inserted.workid )
begin
insert into table2 select * from inserted
end
else
begin
update table1 set tecnicalclass='技师'where tabl1.workid=inserted.workid
end
end
FROM TABLE1 ,(SELECT workid FROM table2 WHERE tecnicalclass='技师') B
WHERE TABLE1.workid=B.workidinsert into table1 s
elect * from table2
where table2.tecnicalclass='技师' and table2.workid not in( select workid from table1)