Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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


Ïà¹ØÎÊ´ð£º

Asp+sql serverÎÊÌâ - Web ¿ª·¢ / ASP

ÎÒÒ»¸öÏîÄ¿£¬Óиö²åÈë²Ù×÷£¬¾ßÌåÊÇÕâÑùµÄ£º
ÎÒÓнø»õÐÅÏ¢±í¡£ÔÚ³ö»õʱѡÔñÏàÓ¦µÄ½ø»õÐÅÏ¢£¬ÊäÈëÊýÁ¿£¬Ñ¡Ôñ²¿Ãź󣬵㱣´æ°´Å¥£¬ÓÉÓÚÍøÂçÑÓʱ£¬µãÒ»ÏÂûÓз´Ó³£¬ÓÚÊÇÓû§¾ÍÓÖµãһϣ¬µ¼ÖÂÒ»´Î²åÈëÁËÁ½Ìõ¼Ç¼:
Àý£º ......

sql - MS-SQL Server / ÒÉÄÑÎÊÌâ

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

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

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

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

MS SQL×÷ÒµÎÊÌâ - MS-SQL Server / Ó¦ÓÃʵÀý

ÈçºÎÔÚSQL2005ÖÐÉ趨¶¨Ê±×÷Òµ£¬±ÈÈç˵¶¨Ê±ÇåÀíijЩ±íµÄÊý¾Ý£¬
»òÕßÊǶ¨Ê±µÄ½«Ä³Ð©±íµÄÊý¾Ýµ¼³öexcel£¡
ÔÚÏߵȴý£¬¼±¼±¼±£¬×îºÃÊÇÏêϸ²½Ö裡
֮ǰÎÒ×öµÄ×÷ÒµÓеãÎÊÌ⣡
°ïUP

²Î¿¼:http://hi.baidu.com/toiota ......

Çë½ÌSQLSERVERµÄÁ½¸öÎÊÌâ - MS-SQL Server / ÒÉÄÑÎÊÌâ

1¡£ÔõÑùʹxp_cmdshellÄÜÍêÕûÊä³ö³¬¹ý255¸ö×Ö·ûµÄ×Ö·û´®¡£
2¡£select ʱ£¬¼ìË÷ËÙ¶ÈÊÇÓëfromºóµÄ TABLE˳ÐòÓйأ¬»¹ÊÇÓëwhereÌõ¼þµÄ˳ÐòÓйØ(TABLEÊý¾Ý¶àÉÙ )
ÔÚϵͳÊôÐÔÉ趨ÀïÓиöÑ¡Ïî,¿ÉÒÔÐ޸ĵ¥×Ö¶ÎÊä³ö×ÖÊýÏÞÖÆ. ......

Ôõô°ÑMDFÊý¾Ýתµ½MySQL£¿ - MS-SQL Server / »ù´¡Àà

Ôõô°ÑMDFÊý¾Ýתµ½MySQL£¿
ÖÁÉٵø½¼Óµ½sqlserverÉÏ

¾ßÌåÔõôŪ°¡ ÎҵıÏÒµÉè¼ÆµÄÊý¾Ý¿âÊÇ´ÓÍøÉÏdownÏÂÀ´µÄ£¿£¿

Ä㻹²»ÈçÖ±½ÓÓÃsqlserverÄØ

º¯Êý¡¢´æ´¢¹ý³Ì¶¼µÃ¸ÄÁË¡£

sqlserverûÔõôÓùý¡£Ò²Ã»Óа²× ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ