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

sql Ë÷Òý ´æ´¢¹ý³Ì

´æ´¢¹ý³Ì
Óŵ㣺
1.ÓÉÓÚÓ¦ÓóÌÐòËæ×Åʱ¼äÍÆÒƻ᲻¶Ï¸ü¸Ä£¬Ôöɾ¹¦ÄÜ£¬T£­SQL¹ý³Ì´úÂë»á±äµÃ¸ü¸´ÔÓ£¬StoredProcedureΪ·â×°´Ë´úÂëÌṩÁËÒ»¸öÌ滻λÖá£
2.Ö´Ðмƻ®£¨´æ´¢¹ý³ÌÔÚÊ×´ÎÔËÐÐʱ½«±»±àÒ룬Õ⽫²úÉúÒ»¸öÖ´Ðмƻ®£­£­ ʵ¼ÊÉÏÊÇ Microsoft SQL ServerΪÔÚ´æ´¢¹ý³ÌÖлñÈ¡ÓÉ T-SQL Ö¸¶¨µÄ½á¹û¶ø±ØÐë²ÉÈ¡µÄ²½ÖèµÄ¼Ç¼¡££©»º´æ¸ÄÉÆÐÔÄÜ¡£
........µ«sql serverа汾£¬Ö´Ðмƻ®ÒÑÕë¶ÔËùÓÐ T-SQL Åú´¦Àí½øÐÐÁË»º´æ£¬¶ø²»¹ÜËüÃÇÊÇ·ñÔÚ´æ´¢¹ý³ÌÖУ¬ËùÒÔû±È½ÏÓÅÊÆÁË¡£
3.´æ´¢¹ý³Ì¿ÉÒÔÓÃÓÚ½µµÍÍøÂçÁ÷Á¿£¬´æ´¢¹ý³Ì´úÂëÖ±½Ó´æ´¢ÓÚÊý¾Ý¿âÖУ¬ËùÒÔ²»»á²úÉú´óÁ¿T-sqlÓï¾äµÄ´úÂëÁ÷Á¿¡£
4.ʹÓô洢¹ý³ÌʹÄúÄܹ»ÔöÇ¿¶ÔÖ´Ðмƻ®µÄÖظ´Ê¹Óã¬ÓÉ´Ë¿ÉÒÔͨ¹ýʹÓÃÔ¶³Ì¹ý³Ìµ÷Óà (RPC) ´¦Àí·þÎñÆ÷ÉϵĴ洢¹ý³Ì¶øÌá¸ßÐÔÄÜ¡£RPC ·â×°²ÎÊýºÍµ÷Ó÷þÎñÆ÷¶Ë¹ý³ÌµÄ·½Ê½Ê¹ÒýÇæÄܹ»ÇáËɵØÕÒµ½Æ¥ÅäµÄÖ´Ðмƻ®£¬²¢Ö»Ðè²åÈë¸üеIJÎÊýÖµ¡£
5.¿Éά»¤ÐԸߣ¬¸üд洢¹ý³Ìͨ³£±È¸ü¸Ä¡¢²âÊÔÒÔ¼°ÖØв¿Êð³ÌÐò¼¯ÐèÒª½ÏÉÙµÄʱ¼äºÍ¾«Á¦¡£
6.´úÂ뾫¼òÒ»Ö£¬Ò»¸ö´æ´¢¹ý³Ì¿ÉÒÔÓÃÓÚÓ¦ÓóÌÐò´úÂëµÄ²»Í¬Î»Öá£
7.¸üºÃµÄ°æ±¾¿ØÖÆ£¬Í¨¹ýʹÓà Microsoft Visual SourceSafe »òij¸öÆäËûÔ´´úÂë¿ØÖƹ¤¾ß£¬Äú¿ÉÒÔÇáËɵػָ´µ½»òÒýÓþɰ汾µÄ´æ´¢¹ý³Ì¡£
8.ÔöÇ¿°²È«ÐÔ£º
a¡¢Í¨¹ýÏòÓû§ÊÚÓè¶Ô´æ´¢¹ý³Ì£¨¶ø²»ÊÇ»ùÓÚ±í£©µÄ·ÃÎÊȨÏÞ£¬ËüÃÇ¿ÉÒÔÌṩ¶ÔÌض¨Êý¾ÝµÄ·ÃÎÊ£»
b¡¢Ìá¸ß´úÂ밲ȫ£¬·ÀÖ¹ SQL×¢È루µ«Î´³¹µ×½â¾ö£¬ÀýÈ磬½«Êý¾Ý²Ù×÷ÓïÑÔ£­£­DML£¬¸½¼Óµ½ÊäÈë²ÎÊý£©£»
c¡¢SqlParameter ÀàÖ¸¶¨´æ´¢¹ý³Ì²ÎÊýµÄÊý¾ÝÀàÐÍ£¬×÷ΪÉî²ã´Î·ÀÓùÐÔ²ßÂÔµÄÒ»²¿·Ö£¬¿ÉÒÔÑéÖ¤Óû§ÌṩµÄÖµÀàÐÍ£¨µ«Ò²²»ÊÇÍòÎÞһʧ£¬»¹ÊÇÓ¦¸Ã´«µÝÖÁÊý¾Ý¿âÇ°µÃµ½¸½¼ÓÑéÖ¤£©¡£
1¡¢Ô¤±àÒ룬´æ´¢¹ý³ÌÔ¤ÏȱàÒëºÃ·ÅÔÚÊý¾Ý¿âÄÚ£¬¼õÉÙ±àÒëÓï¾äËù»¨µÄʱ¼ä¡£
2¡¢»º´æ£¬±àÒëºÃµÄ´æ´¢¹ý³Ì»á½øÈ뻺´æ£¬ËùÒÔ¶ÔÓÚ¾­³£Ö´ÐеĴ洢¹ý³Ì£¬³ýÁ˵ÚÒ»´ÎÖ´ÐÐÍ⣬ÆäËû´ÎÖ´ÐеÄËٶȻáÓÐÃ÷ÏÔÌá¸ß¡£
3¡¢¼õÉÙÍøÂç´«Ê䣬Ìرð¶ÔÓÚ´¦ÀíһЩÊý¾ÝµÄ´æ´¢¹ý³Ì£¬²»±ØÏñÖ±½ÓÓÃsqlÓï¾äʵÏÖÄÇÑù¶à´Î´«ËÍÊý¾Ýµ½¿Í»§¶Ë¡£
4¡¢¸üºÃµÄÀûÓ÷þÎñÆ÷Äڴ棬Ìرð¶ÔÓÚ´¦ÀíÖмäÊý¾ÝÁ¿²»´óµÄÇé¿ö£¬´æ´¢¹ý³ÌÖпÉÒÔÀûÓôæ·ÅÔÚÄÚ´æµÄ±í±äÁ¿¡£
ȱµã£º
1.Èç¹û¸ü¸Ä·¶Î§´óµ½ÐèÒª¶ÔÊäÈë´æ´¢¹ý³ÌµÄ²ÎÊý½øÐиü¸Ä£¬»òÕßÒª¸ü¸ÄÓÉÆä·µ»ØµÄÊý¾Ý£¬ÔòÄúÈÔÐèÒª¸üгÌÐò¼¯ÖеĴúÂëÒÔÌí¼Ó²ÎÊý¡¢¸üРGetValue() µ÷Ó㬵ȵȣ¬Õâʱºò¹À¼Æ±È½Ï·±ËöÁË¡£
2.¿ÉÒÆÖ²ÐÔ²î
ÓÉÓÚ´æ´¢¹ý³Ì½«Ó¦ÓóÌÐò


Ïà¹ØÎĵµ£º

SQLÓïÑÔ»ù´¡£¨3£©

GROUP BY×Ó¾ä
Ö¸¶¨²éѯ½á¹ûµÄ·Ö×éÌõ¼þ
Óï·¨£ºGROUP BY [ALL] group_by_expression_r_r [,n]
      [WITH{CUBE|ROLLUP}]
group_by_expression_r_rÖ¸Ã÷·Ö×éÌõ¼þ£¬Í¨³£ÊÇÒ»¸öÁÐÃû£¬µ«²»ÄÜÊÇÁеıðÃû¡£
ALL·µ»ØËùÓвéѯ½á¹ûµÄ×éºÏ¡£Èç¹ûûÓÐÂú×ãwhere×Ó¾äµÄÊý¾ÝÔòÓÉNULLÖµ¹¹³ÉÊý¾Ý¡£ALLµÄÑ¡Ïî²»Ä ......

SQLÖеĺ¯Êý

sqlÖеÄindexof£¬º¯Êý½éÉÜ
È¡³öÎļþÃûÖеĺó׺Ãû£¬ÀýÈ磺1.exe±ä³Éexe
declare @fileName varchar(100)
set @fileName='aaa.exe'
select substring(@fileName,charindex('.',@fileName)+1,len(@fileName))
------------------------------------------------
--×Ô¶¨Ò庯Êý£ºÈ¡ÎļþÃûµÄÎļþÀàÐÍ£¬ÀýÈç1.exeµÄexe
--- ......

SQL UnionºÍSQL Union AllÓ÷¨

UNION Ö¸ÁîµÄÄ¿µÄÊǽ«Á½¸ö SQL Óï¾äµÄ½á¹ûºÏ²¢ÆðÀ´¡£´ÓÕâ¸ö½Ç¶ÈÀ´¿´£¬ UNION ¸ú JOIN ÓÐЩÐíÀàËÆ£¬ÒòΪÕâÁ½¸öÖ¸Á¿ÉÒÔÓɶà¸ö±í¸ñÖÐߢȡ×ÊÁÏ¡£ UNION µÄÒ»¸öÏÞÖÆÊÇÁ½¸ö SQL Óï¾äËù²úÉúµÄÀ¸Î»ÐèÒªÊÇͬÑùµÄ×ÊÁÏÖÖÀà¡£ÁíÍ⣬µ±ÎÒÃÇÓà UNIONÕâ¸öÖ¸Áîʱ£¬ÎÒÃÇÖ»»á¿´µ½²»Í¬µÄ×ÊÁÏÖµ (ÀàËÆ SELECT DISTINCT)¡£ unionÖ»Êǽ«Á½¸ö½á¹ ......

SQL INNER JOIN ¹Ø¼ü×Ö

SQL INNER JOIN ¹Ø¼ü×Ö
 
SQL INNER JOIN ¹Ø¼ü×Ö
ÔÚ±íÖдæÔÚÖÁÉÙÒ»¸öÆ¥Åäʱ£¬INNER JOIN ¹Ø¼ü×Ö·µ»ØÐС£
INNER JOIN ¹Ø¼ü×ÖÓï·¨
SELECT column_name(s)
from table_name1
INNER JOIN table_name2
ON table_name1.column_name=table_name2.column_name
×¢ÊÍ£ºINNER JOIN Óë JOIN ÊÇÏàͬµÄ¡£
ԭʼµÄ±í (ÓÃÔÚÀ ......

SQL JOIN

SQL JOIN
 
SQL join ÓÃÓÚ¸ù¾ÝÁ½¸ö»ò¶à¸ö±íÖеÄÁÐÖ®¼äµÄ¹Øϵ£¬´ÓÕâЩ±íÖвéѯÊý¾Ý¡£
Join ºÍ Key
ÓÐʱΪÁ˵õ½ÍêÕûµÄ½á¹û£¬ÎÒÃÇÐèÒª´ÓÁ½¸ö»ò¸ü¶àµÄ±íÖлñÈ¡½á¹û¡£ÎÒÃǾÍÐèÒªÖ´ÐÐ join¡£
Êý¾Ý¿âÖеıí¿Éͨ¹ý¼ü½«±Ë´ËÁªÏµÆðÀ´¡£Ö÷¼ü£¨Primary Key£©ÊÇÒ»¸öÁУ¬ÔÚÕâ¸öÁÐÖеÄÿһÐеÄÖµ¶¼ÊÇΨһµÄ¡£ÔÚ±íÖУ¬Ã¿¸öÖ÷¼üµÄ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ