Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Çë½ÌÒ»Ìõ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 - MS-SQL Server / ÒÉÄÑÎÊÌâ

sqlµÄÈí¼þÔÚÄÄÀï¿ÉÒÔÏ°¡£¡ÔÚÍøÉÏÕÒÁËÂù¶à¶¼Óò»ÁË°¡

Ëæ±ã¸ãÒ»D°æ°É£¬

ѸÀ×µÚÒ»¸ö¾Í¿ÉÒÔÓÃ
2000,2005¶¼ÕâÑù

http://119.147.41.16/down?cid=0698C2D64D7D637D90A6D2482298E6717D4F15CD&t=2&fmt=-1 ......

sql ÎÊÌâ - MS-SQL Server / »ù´¡Àà

ÐèÇóÈçÏ£º
ѧԺ 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·ÖÒ³ÓëOracle·ÖÒ³µÄÒÉÎÊ£¿ - Java / Web ¿ª·¢

ÕâÀïÏëÁ˽âÏ£¬¹ØÓÚSQL ServerÖзÖÒ³ºÍOracleÖзÖÒ³£»
ƽ³£Ð´Ó¦ÓóÌÐòµÄʱºò£¬±ÈÈçÓõÄÓïÑÔÊÇJava£¬ÓиöÁбíÒ³Ã棬ÐèÒª¶ÔÊý¾Ý·ÖÒ³ÏÔʾ£»
ÕâÀïÒª·ÖÒ³ÄѵÀ²»ÐèÒª½èÖúJava£¬¶øÖ±½ÓsqlÄÜÖªµÀ·ÖÒ³Âð£¬ÆðÂëÒ²Òª´«¸öÒ³Âë½ ......

asp wap sqlÓï¾äÖлñÈ¡µÄºº×Ö²»ºÃÊ - Web ¿ª·¢ / ASP

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Õ¾Àï ±¾ÉíÓÐ ......

C# SQL µÄUPDATETEXT ÎÊÌâ - .NET¼¼Êõ / C#

A±í ÓÐÁ½¸ö×ֶΠ
  id ΨһÊý×ÖÓò
  InfoTxt text ÀàÐÍ
 ÎÒÏÖÔÚÒª°Ñ id ²»ÊÇ14 µÄËùÓÐ InfoTxt×ֶΠÎı¾ºóÃæ ¶¼¼ÓÉÏ 'aaa' 
°´ÏÂÃæÖ´ÐÐÏÂÀ´ Ö»Óбí×îºóÒ»ÐмÓÉÏÁË 'aaa' ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ