MS SQLÈëÃÅ»ù´¡:Ë÷ÒýÊÓͼ
MS SQLÈëÃÅ»ù´¡:Ë÷ÒýÊÓͼ
ÊÕ²Ø
¡¡
¡¡ÔÚÇ°ÃæÎÒÃÇÒѾÌáµ½¹ýÓйØÊÓͼµÄÏÂÊö¹Ûµã£ºÓÉÓÚÊÓͼ·µ»ØµÄ½á¹û¼¯Óë¾ßÓÐÐÐÁнṹµÄ±íÓÐ×ÅÏàͬµÄ±í¸ñÐÎʽ£¬²¢ÇÒÎÒÃÇ¿ÉÒÔÔÚSQL
Óï¾äÖÐÏñÒýÓñíÄÇÑùÒýÓÃÊÓͼ£¬ËùÒÔÎÒÃdz£°ÑÊÓͼ³ÆΪÐé±í¡£±ê×¼ÊÓͼµÄ½á¹û¼¯²¢²»ÒÔ±íµÄÐÎʽ´æ´¢ÔÚÊý¾Ý¿âÖУ¬¶øÊÇÔÚÖ´ÐÐÒýÓÃÁËÊÓͼµÄ²éѯʱ£¬SQL
Server 2000 ²Å°ÑÏà¹ØµÄ»ù±¾±íÖеÄÊý¾ÝºÏ²¢³ÉÊÓͼµÄÂß¼½á¹¹¡£
¡¡¡¡ÉÏÃæµÄ½áÂÛ³£ÈÃÎÒÃDzúÉúÕâÑùµÄ½¹ÂÇ£ºÓÉÓÚÊÇÔÚÖ´
ÐÐÁËÒýÓÃÁËÊÓͼµÄ²éѯʱ£¬SQL Server 2000
²Å°ÑÏà¹ØµÄ»ù±¾±íÖеÄÊý¾ÝºÏ²¢³ÉÊÓͼµÄÂß¼½á¹¹£¬ÄÇôµ±²éѯËùÒýÓõÄÊÓͼ°üº¬´óÁ¿µÄÊý¾ÝÐлòÉæ¼°µ½¶Ô´óÁ¿Êý¾ÝÐнøÐкϼÆÔËËã»òÁ¬½Ó²Ù×÷£¬ÎãÓ¹ÖÃÒÉ£¬¶¯Ì¬µØ
´´½¨ÊÓͼ½á¹û¼¯½«¸øϵͳ´øÀ´³ÁÖصĸºµ££¬ÓÈÆäÊǾ³£ÒýÓÃÕâÖÖ´óÈÝÁ¿ÊÓͼ¡£
¡¡¡¡½â¾öÕâÒ»ÁîÈËÍ·Í´ÎÊÌâµÄ·½·¨¾ÍÊÇΪÊÓͼ´´½¨¾Û´ØË÷Òý£¬Ö»ÓÐÕâÑù²Å»áÏÔÖøµØÌá¸ßϵͳµÄÐÔÄÜ¡£µ±ÔÚÊÓͼÉÏ´´½¨Á˾۴ØË÷Òýºó£¬ÊÓͼµÄ½á¹û¼¯ÓëÓо۴ØË÷ÒýµÄ±íµÄÊý¾Ý¼¯Ò»ÑùÊÇ´æ´¢ÔÚÊý¾ÝÖеġ£
¡¡¡¡´ËÍ⣬ÔÚÊÓͼÉÏ´´½¨Ë÷Òý»¹»á´øÀ´ÕâÑùµÄºÃ´¦£»ÓÅ»¯Æ÷¿ÉÒÔÔÚÄÇЩÔÚfrom ´Ó¾äÖв»Ö±½ÓÃüÃûÊÓͼµÄ²éѯÖÐʹÓÃÊÓͼË÷Òý£¬¶øÇÒ¶ÔÒÑ´æÔÚµÄÊÓͼ¶øÑÔ£¬ÓÉÓÚ²»±ØÖØбàд²éѯ´úÂ룬´Ó¶øÌá¸ßÁ˲éѯ´ÓË÷ÒýÊÓͼÖмìË÷Êý¾ÝµÄЧÂÊ¡£
¡¡¡¡Èç¹ûÔÚÊÓͼÉÏ´´½¨Ë÷Òý£¬ÄÇôÊÓͼÖеÄÊý¾Ý»á±»Á¢¼´´æ´¢ÔÚÊý¾Ý¿âÖУ¬¶ÔË÷ÒýÊÓͼ½øÐÐÐ޸ģ¬ÄÇôÕâЩÐ޸ĻáÁ¢¼´·´Ó³µ½»ù´¡±íÖС£Í¬Àí£¬¶Ô»ù´¡±íËù½øÐеÄÊý¾ÝÐÞ¸ÄÒ²»á·´Ó³µ½Ë÷ÒýÊÓͼÄÇÀï¡£Ë÷ÒýµÄΩһÐÔ´ó´óÌá¸ßÁËSQL Server ²éÕÒÄÇЩ±»Ð޸ĵÄÊý¾ÝÐС£
¡¡¡¡Î¬»¤Ë÷ÒýÊÓͼ±Èά»¤»ù´¡±íµÄË÷Òý¸üΪ¸´ÔÓ¡£Ëù
ÒÔ£¬Èç¹ûÈÏΪֵµÃÒÔÒòÊý¾ÝÐ޸ĶøÔö¼Óϵͳ¸ºµ£Îª´ú¼ÛÀ´Ìá¸ßÊý¾Ý¼ìË÷µÄËٶȣ¬ÄÇôӦ¸ÃÔÚÊÓͼÉÏ´´½¨Ë÷Òý¡£ÔÚΪÊÓͼ´´½¨Ë÷ÒýÇ°£¬ÊÓͼ±¾Éí±ØÐëÂú×ãÒÔÏÂÌõ¼þ£º
ÔÚÖ´ÐÐCREATE VIEW ÃüÁîʱ£¬±ØÐ뽫ANSI_NULLS ºÍQUOTED_IDENTIFIERÑ¡ÏîÉèÖÃΪON ״̬£»
ÔÚʹÓÃCREATE TABLE ÃüÁî´´½¨Ë÷ÒýËùÒýÓõĻù´¡±íʱ£¬ANSI_NULLS Ñ¡ÏîÓ¦ÉèÖÃΪON£»
¸ÃÊÓͼËùÒýÓõĶÔÏó½ö°üÀ¨»ù´¡±í¶ø²»°üÀ¨ÆäËüµÄÊÓͼ£» ÊÓͼËùÒýÓõĻù´¡±í±ØÐëÓëÊÓͼͬÊôÓÚͬһÊý¾Ý¿âÇÒÓÐÏàͬµÄËùÓÐÕߣ»
ÔÚ´´½¨ÊÓͼʱ±ØÐëʹÓÃSCHEMABINDING Ñ¡Ï
Èç¹ûÊÓͼÒýÓÃÁËÓû§×Ô¶¨Ò庯Êý£¬ÄÇôÔÚ´´½¨ÕâЩÓû§×Ô¶¨Ò庯ÊýʱҲ±ØÐëʹÓÃSCHEMABINDING Ñ¡Ïî £»
ÊÓͼ±ØÐëÒÔowner.objectname µÄÐÎʽÀ´Ê¹ËùÒýÓõıí»òÓû§×Ô¶¨
Ïà¹ØÎĵµ£º
'*************************************************************************
'**Ä£ ¿é Ãû£ºfBackupDatabase_a
'**Ãè Êö£º±¸·ÝÊý¾Ý¿â,·µ»Ø³ö´íÐÅÏ¢,Õý³£»Ö¸´,·µ»Ø""
'**µ÷ ÓãºfBackupDatabase_a "±¸·ÝÎļþÃû","Êý¾Ý¿ ......
ÊéÇ©£ºÇå³ýËùÓÐÊéÇ©¡£ CTRL-SHIFT-F2
ÊéÇ©£º²åÈë»òɾ³ýÊéÇ©(Çл»)¡£ CTRL+F2
ÊéÇ©£ºÒƶ¯µ½ÏÂÒ»¸öÊéÇ©¡£ F2 ¹¦Äܼü
ÊéÇ©£ºÒƶ¯µ½ÉÏÒ»¸öÊéÇ©¡£ SHIFT+F2
È¡Ïû²éѯ¡£ ALT+BREAK
Á¬½Ó£ºÁ¬½Ó¡£ CTRL+O
Á¬½Ó£º¶Ï¿ªÁ¬½Ó¡£ CTRL+F4
Á¬½Ó£º¶Ï¿ªÁ¬½Ó²¢¹Ø±Õ×Ó´°¿Ú¡£ CTRL+F4
Êý¾Ý¿â¶ÔÏóÐÅÏ¢¡£ ALT+F1
±à¼£ºÇå³ý»î¶¯ ......
Ò»¡¢SQL´æ´¢¹ý³ÌµÄ¸ÅÄÓŵ㼰Óï·¨
¡¡¡¡ÕûÀíÔÚѧϰ³ÌÐò¹ý³Ì֮ǰ£¬ÏÈÁ˽âÏÂʲôÊÇ´æ´¢¹ý³Ì?ΪʲôҪÓô洢¹ý³Ì£¬ËûÓÐÄÇЩÓŵã
¡¡¡¡¶¨Ò壺½«³£ÓõĻòºÜ¸´ÔӵŤ×÷£¬Ô¤ÏÈÓÃSQLÓï¾äдºÃ²¢ÓÃÒ»¸öÖ¸¶¨µÄÃû³Æ´æ´¢ÆðÀ´, ÄÇôÒÔºóÒª½ÐÊý¾Ý¿âÌṩÓëÒѶ¨ÒåºÃµÄ´æ´¢¹ý³ÌµÄ¹¦ÄÜÏàͬµÄ·þÎñʱ,Ö»Ðèµ÷ÓÃexecute,¼´¿É×Ô¶¯Íê³ÉÃüÁî ......
/*»ñÈ¡Öظ´¼Ç¼ÖнÏСµÄÄǸöID*/ create table tmp_Repeat as select min(id) as id from poi group by idcode having count(*) >1; /*±¸·Ýɾ³ýµÄÊý¾Ý*/ select * from poi where id in (select id from tmp_repeat) /*ɾ³ýÖظ´¼Ç¼ÖÐID½ÏСµÄÄÇÌõ
select replace('°¢¹ðÊǸöºÃº¢×Ó','°¢¹ð','СÏÍ') from du ......