Çë½ÌÒ»ÌõSQLÐÞ¸ÄÌí¼ÓÓï¾ä - MS-SQL Server / Ó¦ÓÃʵÀý
ÓÐÁ½¸ö±íT1ºÍT2£¬
T1ÈçÏ£º
±àºÅ ÐÕÃû ÐԱ𠲿ÃÅ
001 ZZ ÄÐ ÒµÎñ²¿
002 YY Å® ¾Ïú²¿
003 XX Å® Éú²ú²¿
004 WW ÄÐ ÏúÊÛ²¿
005 ¡¡
T2ÈçÏ£º
±àºÅ ÐÕÃû ²¿ÃÅ
001 ZZ ÄÐ ÒµÎñ²¿
£¨Î޼Ǽ£©
003 XX Å® ÏúÊÛ²¿£¨²»Í¬£©
005 ¡¡
ÎÒÏë¶Ô±ÈÁ½¸ö±íÖеıàºÅ£¬
ÕÒ³öT2ÖпÕȱµÄ±àºÅ½«T1µÄÄÚÈݼÓÉÏ£¬ÒÑÓеıàºÅ¶ÔӦѡÏî¶Ô±ÈÄÚÈÝ£¬Èç¸ü¸ÄÔòT2Ò²¸ü¸Ä
¾ÍÊǸú×ÅT1µÄ±ê×¼×ߣ¬Çë½Ì´ó¼ÒÔõôʵÏÖ£¬Ð»Ð»£¡
ÊÇÒª´¥·¢Æ÷Âð?
Èç¹ûÊÇÒ»´¸×ÓÂòÂô,ÔòÈçÏÂ:
SQL code:
--1.update
update t2
set ÐÕÃû = t1.ÐÕÃû ,
²¿ÃÅ = t1.²¿ÃÅ
from t2 , t1
where t2.񅧏 = t1.񅧏
--2.insert
insert into t2 select ±àºÅ, ÐÕÃû ,²¿ÃÅ from t2 where t2.±àºÅ not in (select ±àºÅ from t1)
SQL code:
if not exists(select 1 from t1 inner join t2 where t1.񅧏 = t2.񅧏)
insert into t2(±àºÅ,ÐÕÃû,ÐÔ±ð,²¿ÃÅ) select ±àºÅ,ÐÕÃû,ÐÔ±ð,²¿ÃÅ from t1
else
update t1 set ²¿ÃÅ = t2.²¿ÃÅ from t2 where t1.±àºÅ = t2.±àºÅ
-- Ö»ÊÇÒ»´ÎÐԵģ¬Èç¹ûÒ»Ö±ÒªÕâÑù£¬Òª×ö´¥·¢Æ÷
ÎÒÊÇÓÃVC++6.0±àµÄ£¬¾ÍÏëÿ´Î°´¼üÖ´ÐÐÒ»´ÎÕ⹦ÄÜ
SQL code
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.C
Ïà¹ØÎÊ´ð£º
sqlµÄÈí¼þÔÚÄÄÀï¿ÉÒÔÏ°¡£¡ÔÚÍøÉÏÕÒÁËÂù¶à¶¼Óò»ÁË°¡
Ëæ±ã¸ãÒ»D°æ°É£¬
ѸÀ×µÚÒ»¸ö¾Í¿ÉÒÔÓÃ
2000,2005¶¼ÕâÑù
http://119.147.41.16/down?cid=0698C2D64D7D637D90A6D2482298E6717D4F15CD&t=2&fmt=-1 ......
ÐèÇóÈçÏ£º
ѧԺ academy£¨aid,aname£©
°à¼¶ class£¨cid,cname,aid£©
ѧÉú stu(sid,sname,aid,cid)
סËÞÇø region(rid,rname)
ËÞÉáÂ¥ build(bid,rid,bnote) bnoteÊÇ¡®ÄС¯/¡®Å®¡¯
ËÞÉá dorm(did,rid,bid£¬bedn ......
ÕâÀïÏëÁ˽âÏ£¬¹ØÓÚSQL ServerÖзÖÒ³ºÍOracleÖзÖÒ³£»
ƽ³£Ð´Ó¦ÓóÌÐòµÄʱºò£¬±ÈÈçÓõÄÓïÑÔÊÇJava£¬ÓиöÁбíÒ³Ã棬ÐèÒª¶ÔÊý¾Ý·ÖÒ³ÏÔʾ£»
ÕâÀïÒª·ÖÒ³ÄѵÀ²»ÐèÒª½èÖúJava£¬¶øÖ±½ÓsqlÄÜÖªµÀ·ÖÒ³Âð£¬ÆðÂëÒ²Òª´«¸öÒ³Âë½ ......
SQL code:
rs.open "select * from guide where city_name='±±¾©' order by pai desc",conn,1,1
do while not rs.eof or rs.bof
¡£¡£
¡£¡£
¡£¡£
rs.movenext
loop
Õâ¸ösqlÓï¾äÔÚwapÕ¾Àï ±¾ÉíÓÐ ......
A±í ÓÐÁ½¸ö×Ö¶Î
id ΨһÊý×ÖÓò
InfoTxt text ÀàÐÍ
ÎÒÏÖÔÚÒª°Ñ id ²»ÊÇ14 µÄËùÓÐ InfoTxt×ֶΠÎı¾ºóÃæ ¶¼¼ÓÉÏ 'aaa'
°´ÏÂÃæÖ´ÐÐÏÂÀ´ Ö»Óбí×îºóÒ»ÐмÓÉÏÁË 'aaa' ......