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

SQL Server µÃµ½ÐкŵÄSQL

SQL Server µÃµ½ÐкŵÄSQL
ʹÓÃÁÙʱ±í£º
select   id=identity(int,1,1),value   into   #temp   from   YourTable  
  select   *   from   #temp  
  drop   table   #temp  
È¡µÃµÚ11µ½20ÐмǼ£º
select   IDENTITY(int,   1,1)   AS   ID_Num,*   into   #temp   from   ±í  
  select   *   from   #temp   where   ID_Num>10   and   ID_Num<=20
»ò  
  SELECT   Top   @PageSize   *  
            from   T  
          WHERE   SortField   NOT   IN   (SELECT   TOP   @PageSize   *   @Pagei   SortField  
                                                              from   T  
                                                      ORDER   BY   SortField  
                                                          )  
    ORDER   BY   SortField
REF:http://topic.csdn.net/t/20021022/21/1116380.html


Ïà¹ØÎĵµ£º

ÔÚSQL Server 2005ÖÐÓô洢¹ý³ÌʵÏÖËÑË÷¹¦ÄÜ


ÏÖÔںܶàÍøÕ¾¶¼ÌṩÁËÕ¾ÄÚµÄËÑË÷¹¦ÄÜ£¬Óеĺܼòµ¥ÔÚSQLÓï¾äÀï¼ÓÒ»¸öÌõ¼þÈ磺where names like ‘%words%’¾Í¿ÉÒÔʵÏÖ×î»ù±¾µÄËÑË÷ÁË¡£
    ÎÒÃÇÀ´¿´¿´¹¦ÄÜÇ¿´óÒ»µã£¬¸´ÔÓÒ»µãµÄËÑË÷ÊÇÈçºÎʵÏֵģ¨ÔÚSQL¡¡£Ó£Å£Ò£Ö£Å£Ò£²£°£°£¯£²£°£°£µÍ¨¹ý´æ´¢¹ý³ÌʵÏÖËÑË÷Ëã·¨£©¡£
    ÎÒÃÇ ......

ÍƼö̽ÌÖÕä²Ø¡¾¾­µäSQLÓï¾ä´óÈ«¡¿

ÏÂÁÐÓï¾ä²¿·ÖÊÇMssqlÓï¾ä£¬²»¿ÉÒÔÔÚaccessÖÐʹÓá£
¡¡¡¡SQL·ÖÀࣺ
¡¡¡¡DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
¡¡¡¡DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
¡¡¡¡DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
¡¡¡¡Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
¡¡¡¡1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
......

ÈýÖÖSQL·ÖÒ³·¨¡¾×ªÌû¡¿

Ó¦Ò»¸öÅóÓѵÄÒªÇó£¬ÌùÉÏÊղصÄSQL³£Ó÷ÖÒ³µÄ°ì·¨¡«¡«

±íÖÐÖ÷¼ü±ØÐëΪ±êʶÁУ¬[ID] int IDENTITY (1,1)

1.·ÖÒ³·½°¸Ò»£º(ÀûÓÃNot InºÍSELECT TOP·ÖÒ³)

Óï¾äÐÎʽ£º 
SELECT TOP Ò³¼Ç¼ÊýÁ¿ *
from ±íÃû
WHERE (ID NOT IN
  (SELECT TOP (ÿҳÐÐÊý*(Ò³Êý-1)) ID
  from ± ......

½«Excelµ¼ÈëSQL SERVER2005Êý¾Ý¿â

/*
±¾ÎÄרעÓÚ½«Excelµ¼ÈëSQL SERVER2005Êý¾Ý¿â
´Ë·¾¶ÏµÄÕâ¸ö¹¤¾ß£¬ÊÇSQL SERVER2005 ÓÃÀ´µ¼Èëµ¼³öÊý¾ÝµÄ¹¤¾ß¡£
C:\Program Files\Microsoft SQL Server\90\DTS\Binn\DTSWizard.exe
Ò»°ãÔÚÊý¾Ý¿âÃûÉÏ--ÓÒ¼ü-->Tasks-->Import Data -->½çÃæ¾Í³öÀ´ÁË£¬ºÍµã»÷ÉÏÃæµÄ¹¤¾ßÊÇÒ»¸ö¶«Î÷¡£
Ê×´ÎʹÓÃÕâ¸öD ......

ÌùÉÏÊղصÄSQL³£Ó÷ÖÒ³µÄ°ì·¨¡«¡«

Ó¦Ò»¸öÅóÓѵÄÒªÇó£¬ÌùÉÏÊղصÄSQL³£Ó÷ÖÒ³µÄ°ì·¨¡«¡«
±íÖÐÖ÷¼ü±ØÐëΪ±êʶÁУ¬[ID] int IDENTITY (1,1)
1.·ÖÒ³·½°¸Ò»£º(ÀûÓÃNot InºÍSELECT TOP·ÖÒ³)
Óï¾äÐÎʽ£º 
SELECT TOP Ò³¼Ç¼ÊýÁ¿ *
from ±íÃû
WHERE (ID NOT IN
  (SELECT TOP (ÿҳÐÐÊý*(Ò³Êý-1)) ID
  from ±íÃû
  ORDER BY ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ