SQL ServerÊý¾Ý¿â¿ª·¢µÄ¶þʮһÌõ¾ü¹æ(SQLÊÕ²Ø)
Èç¹ûÄãÕýÔÚ¸ºÔðÒ»¸ö»ùÓÚSQL ServerµÄÏîÄ¿£¬»òÕßÄã¸Õ¸Õ½Ó´¥SQL Server£¬Ä㶼ÓпÉÄÜÒªÃæÁÙһЩÊý¾Ý¿âÐÔÄܵÄÎÊÌ⣬ÕâƪÎÄÕ»áΪÄãÌṩһЩÓÐÓõÄÖ¸µ¼£¨ÆäÖдó¶àÊýÒ²¿ÉÒÔÓÃÓÚÆäËüµÄDBMS£©¡£
ÔÚÕâÀÎÒ²»´òËã½éÉÜʹÓÃSQL ServerµÄÇÏÃÅ£¬Ò²²»ÄÜÌṩһ¸ö°üÖΰٲ¡µÄ·½°¸£¬ÎÒËù×öµÄÊÇ×ܽáһЩ¾Ñé----¹ØÓÚÈçºÎÐγÉÒ»¸öºÃµÄÉè¼Æ¡£ÕâЩ¾ÑéÀ´×ÔÎÒ¹ýÈ¥¼¸ÄêÖоÊܵĽÌѵ£¬Ò»Ö±À´£¬ÎÒ¿´µ½Ðí¶àͬÑùµÄÉè¼Æ´íÎó±»Ò»´ÎÓÖÒ»´ÎµÄÖظ´¡£
Ò»¡¢Á˽âÄãÓõŤ¾ß
²»ÒªÇáÊÓÕâÒ»µã£¬ÕâÊÇÎÒÔÚÕâƪÎÄÕÂÖн²ÊöµÄ×î¹Ø¼üµÄÒ»Ìõ¡£Ò²ÐíÄãÒ²¿´µ½ÓкܶàµÄSQL Server³ÌÐòԱûÓÐÕÆÎÕÈ«²¿µÄT-SQLÃüÁîºÍSQL ServerÌṩµÄÄÇЩÓÐÓõŤ¾ß¡£
“ʲô£¿ÎÒÒªÀË·ÑÒ»¸öÔµÄʱ¼äÀ´Ñ§Ï°ÄÇЩÎÒÓÀÔ¶Ò²²»»áÓõ½µÄSQLÃüÁ£¿£¿”£¬ÄãÒ²Ðí»áÕâÑù˵¡£¶ÔµÄ£¬Äã²»ÐèÒªÕâÑù×ö¡£µ«ÊÇÄãÓ¦¸ÃÓÃÒ»¸öÖÜÄ©ä¯ÀÀËùÓеÄT-SQLÃüÁî¡£ÔÚÕâÀÄãµÄÈÎÎñÊÇÁ˽⣬½«À´£¬µ±ÄãÉè¼ÆÒ»¸ö²éѯʱ£¬Äã»á¼ÇÆðÀ´£º“¶ÔÁË£¬ÕâÀïÓÐÒ»¸öÃüÁî¿ÉÒÔÍêȫʵÏÖÎÒÐèÒªµÄ¹¦ÄÜ”£¬ÓÚÊÇ£¬µ½MSDN²é¿´Õâ¸öÃüÁîµÄÈ·ÇÐÓï·¨¡£
¶þ¡¢²»ÒªÊ¹ÓÃÓαê
ÈÃÎÒÔÙÖظ´Ò»±é£º²»ÒªÊ¹ÓÃÓαꡣÈç¹ûÄãÏëÆÆ»µÕû¸öϵͳµÄÐÔÄܵĻ°£¬ËüÃǵ¹ÊÇÄã×îÓÐЧµÄÊ×Ñ¡°ì·¨¡£´ó¶àÊýµÄ³õѧÕ߶¼Ê¹ÓÃÓα꣬¶øûÓÐÒâʶµ½ËüÃǶÔÐÔÄÜÔì³ÉµÄÓ°Ïì¡£ËüÃÇÕ¼ÓÃÄڴ棬»¹ÓÃËüÃÇÄÇЩ²»¿É˼ÒéµÄ·½Ê½Ëø¶¨±í£¬ÁíÍ⣬ËüÃǼòÖ±¾ÍÏñÎÏÅ£¡£¶ø×îÔã¸âµÄÊÇ£¬ËüÃÇ¿ÉÒÔʹÄãµÄDBAËùÄÜ×öµÄÒ»ÇÐÐÔÄÜÓÅ»¯µÈÓÚû×ö¡£²»ÖªÄãÊÇ·ñÖªµÀÿִÐÐÒ»´ÎFETCH¾ÍµÈÓÚÖ´ÐÐÒ»´ÎSELECTÃüÁÕâÒâζ×ÅÈç¹ûÄãµÄÓαêÓÐ10000Ìõ¼Ç¼£¬Ëü½«Ö´ÐÐ10000´ÎSELECT£¡Èç¹ûÄãʹÓÃÒ»×éSELECT¡¢UPDATE»òÕßDELETEÀ´Íê³ÉÏàÓ¦µÄ¹¤×÷£¬Äǽ«ÓÐЧÂʵĶࡣ
³õѧÕßÒ»°ãÈÏΪʹÓÃÓαêÊÇÒ»ÖֱȽÏÊìϤºÍÊæÊʵıà³Ì·½Ê½£¬¿ÉºÜ²»ÐÒ£¬Õâ»áµ¼ÖÂÔã¸âµÄÐÔÄÜ¡£ÏÔÈ»£¬SQLµÄ×ÜÌåÄ¿µÄÊÇÄãҪʵÏÖʲô£¬¶ø²»ÊÇÔõÑùʵÏÖ¡£
ÎÒÔø¾ÓÃT-SQLÖØдÁËÒ»¸ö»ùÓÚÓαêµÄ´æ´¢¹ý³Ì£¬ÄǸö±íÖ»ÓÐ100,000Ìõ¼Ç¼£¬ÔÀ´µÄ´æ´¢¹ý³ÌÓÃÁË40·ÖÖÓ²ÅÖ´ÐÐÍê±Ï£¬¶øеĴ洢¹ý³ÌÖ»ÓÃÁË10ÃëÖÓ¡£ÔÚÕâÀÎÒÏëÄãÓ¦¸Ã¿ÉÒÔ¿´µ½Ò»¸ö²»³ÆÖ°µÄ³ÌÐòÔ±¾¿¾¹ÔÚ¸ÉÁËʲô£¡£¡£¡
ÎÒÃÇ¿ÉÒÔдһ¸öС³ÌÐòÀ´È¡µÃºÍ´¦ÀíÊý¾Ý²¢ÇÒ¸üÐÂÊý¾Ý¿â£¬ÕâÑù×öÓÐʱ»á¸üÓÐЧ¡£¼Çס£º¶ÔÓÚÑ»·£¬T-SQLÎÞÄÜΪÁ¦¡£
ÎÒÔÙÖØÐÂÌáÐÑһϣºÊ¹ÓÃÓαêûÓкô¦¡£³ýÁËDBAµÄ¹¤×÷Í⣬ÎÒ´ÓÀ´Ã»Óп´µ½¹ýʹÓÃÓαê¿ÉÒÔÓÐЧµÄÍê³ÉÈκι¤×÷¡£
Èý¡¢¹æ·¶»¯ÄãµÄÊý¾Ý±í
Ϊʲô²»¹æ·¶»¯Êý¾Ý¿â£¿´ó¸ÅÓÐÁ½¸ö½è¿Ú£º³öÓÚÐÔÄܵĿ¼ÂǺʹ¿
Ïà¹ØÎĵµ£º
1.°´ÐÕÊϱʻÅÅÐò:
Select * from TableName Order By CustomerName Collate Chinese_PRC_Stroke_ci_as
2.·ÖÒ³SQLÓï¾ä
select * from(select (row_number() OVER (ORDER BY tab.ID Desc)) as rownum,tab.* from ±íÃû As tab) As t where rownum between ÆðʼλÖà And ½áÊøλÖÃ
3.»ñÈ¡µ±Ç°Êý¾Ý¿âÖеÄËùÓÐÓû§± ......
1.update a set a.nickname=b.nickname from tab1 a,tab2 b where a.username=b.username
2.Update student_score set
student_score.level=level_about.level from
level_about where student.score
between level_about.start_score and level_about.end_score ......
SQLÊý¾Ý»Ö¸´Èí¼þ Log Explorer for SQL Server v4.0
log explorerʹÓõļ¸¸öÎÊÌâ
¡¡¡¡1)¶ÔÊý¾Ý¿â×öÁËÍêÈ« ²îÒì ºÍÈÕÖ¾±¸·Ý
¡¡¡¡±¸·ÝʱѡÓÃÁËɾ³ýÊÂÎñÈÕÖ¾Öв»»î¶¯µÄÌõÄ¿
¡¡¡¡ÔÙÓÃLog explorer´òÊÔͼ¿´ÈÕ־ʱ
¡¡¡¡ÌáʾNo log recorders found that match the filter£¬would you like to view unfiltered ......
Óû§×Ô¶¨Ò庯Êý£¨User Defined Functions£©ÊÇSQL Server µÄÊý¾Ý¿â¶ÔÏó£¬Ëü²»ÄÜÓÃÓÚÖ´ÐÐһϵÁиıäÊý¾Ý¿â״̬µÄ²Ù×÷£¬µ«Ëü¿ÉÒÔÏñϵͳº¯ÊýÒ»ÑùÔÚ²éѯ»ò´æ´¢¹ý³ÌµÈµÄ³ÌÐò¶ÎÖÐʹÓã¬Ò²¿ÉÒÔÏñ´æ´¢¹ý³ÌÒ»Ñùͨ¹ý EXECUTE ÃüÁîÀ´Ö´ÐС£Óû§×Ô¶¨Ò庯ÊýÖд洢ÁËÒ»¸öTransact-SQL Àý³Ì£¬¿ÉÒÔ·µ»ØÒ»¶¨µÄÖµ¡£
¡¡¡¡ÔÚSQL Server Öиù¾Ýº ......
SQL ServerÊý¾Ý¿âÖвð·Ö×Ö·û´®º¯ÊýµÄ¾ßÌå·½·¨£º
ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º
¡¡¡¡CREATE¡¡ FUNCTION uf_StrSplit '1.1.2.50','.'
¡¡¡¡(@origStr varchar(7000),¡¡ --´ý²ð·ÖµÄ×Ö·û´®
¡¡¡¡@markStr varchar(100))¡¡¡¡--²ð·Ö±ê¼Ç£¬Èç','
¡¡¡¡RETURNS @splittable table
¡¡¡¡(
¡¡ ¡¡str_id¡¡¡¡varchar(4000) NOT NULL, --±àºÅID ......