SQLÖÐûÓü¯ºÏµÄminus,ÓÃunionʵÏÖ
ÁгöTableAÖÐÓеĶøTableBÖÐûÓÐ, ÒÔ¼°BÖÐÓжøAÖÐûÓеļǼ£º
ÆäÖÐÁ½¸ö±íµÄ½á¹¹Ïàͬ£¬Ñ¡ÔñµÄKey¿ÉÒÔ¶à¸ö
Select Key from
( select * from TableA
Union select * from TableB
)
group by Key
having count(Key)=1
ÁгöTableAÖÐÓеĶøTableBÖÐûÓеļǼ£º
Select Key from
( (select * from TableA
Union all select * from TableB)
Union select * from TableB
)a
group by Key
having count(Key)=1
Ïà¹ØÎĵµ£º
¼ò½é
ÔÚÕâƪÎÄÕÂÖУ¬ÎÒÁоÙһЩsqlÓï¾äÀ´½éÉÜÊý¾Ý¿â£¬Êý¾Ý±í£¬ÊÓͼµÈµÈ¡£µ±ÎÒÃÇÔÚʹÓòéѯ²éѯ²Ù×÷ʱÕâЩsqlÓï¾ä¶¼ÊǷdz£ÓÐÓõġ£ËäÈ»ÔÚsql server¶ÔÏóä¯ÀÀÆ÷ÖÐÎÒÃÇÒ²¿ÉÒÔ»ñµÃÕâЩÓï¾ä£¬µ«ÊÇÈç¹ûÎÒÃÇдÕâЩÓï¾äʱÎÒÃÇ¿ÉÒÔ½«Ëü×Ô¶¨Òå¡£Õâ¾ÍÒâζ×ÅÎÒÃÇ¿ÉÒÔ¸øÓè×Ô¼ºµÄÐèÇóÀ´¹ýÂ˽á¹û¡£
sqlÓï¾äÁбí
ÈçºÎÁоÙsql serverµ±Ç°Á ......
MS SQL SERVER 2005È«ÎÄË÷Òýѧϰ±Ê¼ÇÒ»
ÏÈÁ˽âÒ»ÏÂÈ«ÎÄË÷ÒýÊÇÈçºÎ´´½¨ºÍʹÓõÄ
´´½¨È«ÎÄË÷Òý:
ÔÚMS SQL SERVER 2005Àï,È«ÎÄË÷ÒýÊÇÒ»¸öµ¥¶ÀµÄ·þÎñÏî,ĬÈÏÊÇÆô¶¯µÄ,µ«ÊÇûÓÐÔÊÐíÊý¾Ý¿âÆôÓÃÈ«ÎÄË÷Òý,Èç¹ûÒ ......
“¾¹ý²âÊÔÎÒÃÇ·¢ÏÖSQL Server 2008µ±Öеı¸·ÝѹËõ¹¦ÄÜ¿ÉÒÔ1-3±¶µÄѹËõ±È£¬´Ó¶ø¼«´óµÄ¼õÉÙ±¸·ÝËùÐèµÄ´ÅÅ̿ռ䡣”Alexey Yeltsov, ΢Èíϵͳ¹ÜÀíÔ±Ö÷¹Ü¡£
΢ÈíÔÚÈ«ÊÀ½ç¹²ÓÐ6Íò¶àÃûÔ±¹¤£¬ÔÚ2006ÄêµÄ²ÆÕþÊÕÈ볬¹ýÁË500ÒÚÃÀ½ð£¬Óë´ËͬʱҲ²úÉúÁË´óÁ¿ÄÚ²¿Êý¾Ý£¬¹«Ë¾Ï£Íû¶ÔÕâЩÊý¾Ý½øÐм¯ÖÐÒÔ±ãÌṩ¿Í»§µÄ¼¯³É»¯ÊÓͼ¡£ ......
/********************************
¹¦ÄÜ£º»ñÈ¡±íµÄ¿Õ¼ä·Ö²¼Çé¿ö
**********************************/
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tablespaceinfo]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
create table tablespaceinfo   ......
--ÔÚÈÕ³£Î¬»¤£¬¿ª·¢Öг£Óöµ½Ð´Ò»ÏµÁнṹÀàÐ͵ÄsqlÓï¾ä£¬ºÜ·³ºÜÀÛÆäʵ¿ÉÒÔ
--ÀûÓÃSQL*PLUS»·¾³ÃüÁî Éú³É½Å±¾Îļþ
set heading off --¹Ø±ÕÁеıêÌâ
set feedback off --¹Ø±Õ·´À¡ÐÅÏ¢
  ......