SQLÓï¾äЧÂÊÎÊÌâµÄ¼¸µã×ܽá
1. SQLÓÅ»¯µÄÔÔòÊÇ£º
½«Ò»´Î²Ù×÷ÐèÒª¶ÁÈ¡µÄBLOCKÊý¼õµ½×îµÍ,¼´ÔÚ×î¶ÌµÄʱ¼ä´ïµ½×î´óµÄÊý¾ÝÍÌÍÂÁ¿¡£
µ÷Õû²»Á¼SQLͨ³£¿ÉÒÔ´ÓÒÔϼ¸µãÇÐÈ룺
¼ì²é²»Á¼µÄSQL£¬¿¼ÂÇÆäд·¨ÊÇ·ñ»¹ÓпÉÓÅ»¯ÄÚÈÝ
¼ì²é×Ó²éѯ ¿¼ÂÇSQL×Ó²éѯÊÇ·ñ¿ÉÒÔÓüòµ¥Á¬½ÓµÄ·½Ê½½øÐÐÖØÐÂÊéд
¼ì²éÓÅ»¯Ë÷ÒýµÄʹÓÃ
¿¼ÂÇÊý¾Ý¿âµÄÓÅ»¯Æ÷
2. ±ÜÃâ³öÏÖSELECT * from table Óï¾ä£¬ÒªÃ÷È·²é³öµÄ×ֶΡ£
3. ÔÚÒ»¸öSQLÓï¾äÖУ¬Èç¹ûÒ»¸öwhereÌõ¼þ¹ýÂ˵ÄÊý¾Ý¿â¼Ç¼Խ¶à£¬
¶¨Î»Ô½×¼È·£¬Ôò¸ÃwhereÌõ¼þÔ½Ó¦¸ÃÇ°ÒÆ¡£
4. ²éѯʱ¾¡¿ÉÄÜʹÓÃË÷Òý¸²¸Ç¡£¼´¶ÔSELECTµÄ×ֶν¨Á¢¸´ºÏË÷Òý£¬
ÕâÑù²éѯʱֻ½øÐÐË÷ÒýɨÃ裬²»¶ÁÈ¡Êý¾Ý¿é¡£
5. ÔÚÅжÏÓÐÎÞ·ûºÏÌõ¼þµÄ¼Ç¼ʱ½¨Òé²»ÒªÓÃSELECT COUNT £¨*£©ºÍselect top 1 Óï¾ä¡£
6. ʹÓÃÄÚ²ãÏÞ¶¨ÔÔò£¬ÔÚÆ´Ð´SQLÓï¾äʱ£¬½«²éѯÌõ¼þ·Ö½â¡¢·ÖÀ࣬
²¢¾¡Á¿ÔÚSQLÓï¾äµÄ×îÀï²ã½øÐÐÏÞ¶¨£¬ÒÔ¼õÉÙÊý¾ÝµÄ´¦ÀíÁ¿¡£
7. Ó¦¾ø¶Ô±ÜÃâÔÚorder by×Ó¾äÖÐʹÓñí´ïʽ¡£
8. Èç¹ûÐèÒª´Ó¹ØÁª±í¶ÁÊý¾Ý£¬¹ØÁªµÄ±íÒ»°ã²»Òª³¬¹ý7¸ö¡£
9. СÐÄʹÓà IN ºÍ OR£¬ÐèҪעÒâIn¼¯ºÏÖеÄÊý¾ÝÁ¿¡£½¨Ò鼯ºÏÖеÄÊý¾Ý²»³¬¹ý200¸ö¡£
10. <> Óà < ¡¢ > ´úÌæ£¬>ÓÃ>=´úÌæ£¬<ÓÃ<=´úÌæ£¬ÕâÑù¿ÉÒÔÓÐЧµÄÀûÓÃË÷Òý¡£
11. ÔÚ²éѯʱ¾¡Á¿¼õÉÙ¶Ô¶àÓàÊý¾ÝµÄ¶ÁÈ¡°üÀ¨¶àÓàµÄÁÐÓë¶àÓàµÄÐС£
12. ¶ÔÓÚ¸´ºÏË÷ÒýҪעÒ⣬ÀýÈçÔÚ½¨Á¢¸´ºÏË÷ÒýʱÁеÄ˳ÐòÊÇF1£¬F2£¬F3£¬
ÔòÔÚwhere»òorder by×Ó¾äÖÐÕâЩ
Ïà¹ØÎĵµ£º
--´´½¨Óαê
DECLARE Cursor1 CURSOR FOR
SELECT NODE_NO,NODE_VALUE,SUM(RESALE_SUM-RESALERETU_SUM+SALE_SUM-SALERETU_SUM) sale_sum,
SUM(STORE_SUM) sum_store,SUM(STORE_SUM) store_sum,
sum(RESALE_PROFIT-RESALERETU_PROFIT+SALE_PROFIT-SALERETU_PROFIT-ADJUST_PROFIT) sale_profit
from ......
ÿÌ죬ÿÖܵÄÖ´ÐÐ
±ÈÈç¿ÉÒÔ¿ØÖÆÃ¿ÌìÖ»ÄÜͶƱÈý´Î¡£
ÿÖÜҪͳ¼ÆÒ»ÏÂͶƱÊý¡£
1¡¢Äã±ØÐ뿪Æô´úÀí·þÎñsql server agent
2¡¢ÔÚÆóÒµ¹ÜÀíÆ÷À´ò¿ª“¹ÜÀí—>sqlserver´úÀí—>×÷Òµ”£¬ÐÂÔö×÷Òµ£¬Ð½¨“²½Ö蔣¬ÔÚ²½ÖèÀïÌîÈëÄãÒª×ªÒÆµÄSQLÓï¾äµ½“ÃüÁòÀȻºóн¨“µ ......
bulk collectÊÇ¿ÉÒÔ¿´×öÊÇÒ»ÖÖÅú»ñÈ¡µÄ·½Ê½£¬ÔÚÎÒÃǵÄplsqlµÄ´úÂë¶ÎÀï¾³£×÷ΪintoµÄÀ©Õ¹À´Ê¹Ó᣶ÔÓÚselect id into v from .... ÊÇÒ»¸ö³£ÓõÄÓ÷¨¡£²»¹ýÕâÀïÖ»ÄÜÊÇ·µ»Øµ¥Ìõ¼Ç¼µÄʱºò£¬²ÅÄÜʹÓã¬Èç¹ûÊÇÓжàÌõ¼Ç¼ÎÒÃǾͲ»ÄÜÓÃÕâÑùµÄ·½Ê½£¬¶øÊÇʹÓÃfetchºÍÑ»·µÄ·½Ê½£¬²»½öʹÓÃÂé·³£¬¶øÇÒÐÔÄÜÒ²µ×Ï£¬ÕâʱÎÒÃǵÄbulk coll ......
ÈçºÎÁ¬½Óµ½Áíһ̨»úÆ÷ÉϵÄsql server 2005
Ò»¡¢Òª½øÐÐÁ½¸öµØ·½µÄÉèÖÃ
1 µã¿ªÊ¼—³ÌÐò—sql server 2005 –ÅäÖù¤¾ß—sql server 2005Ó¦ÓÃÅäÖÃÆ÷ ,Èçͼ£º
Ñ¡±¾µØÁ¬½ÓºÍÔ¶³ÌÁ¬½ÓÖÐµÄ ½öʹÓÃtcp/ip»ò& ......