delete from c insert into c select a,b,c,d from b union all select a,b,c,1 from a
ҪʵÏÖÒÔÉϹ¦ÄÜ Ð´³ÉÒ»Ìõsql Ôõôд²ÅºÃ£¿exec('delete from c; insert into c select a,b,c,d from b union all select a,b,c,1 from a' ) SQL code: exec('delete from c; insert into c select a,b,c,d from b union all select a,b,c,1 from a' )
¡£¡£¡£¡£¡£¡£ .. ÏÖѧÏÖÂô SQL code:
-- SQL Server 2008 statement merge c as t using (select a,b,c,d from b union all select a,b,c,1 from a) as s(a,b,c,d) on (t.a=s.a and t.b=s.b and t.c=s.c and t.d=s.d) when not matched by source then delete when not matched then insert (a,b,c,d) values(s.a,s.b,s.c,s.d);
²Î¿¼£º http://school.itzcn.com/index.html# ÉÏÃæ½²½âµÄ±È½ÏÏêϸ£¬Ï£Íû¶ÔÂ¥Ö÷ÓÐËù°ïÖú¡£ ¶¥Ò»¸ö£¬ÊÇÕâô¸öÀí exec('delete from c; i