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

ÈýÖÖ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 ID))
  ORDER BY ID
//×Ô¼º»¹¿ÉÒÔ¼ÓÉÏһЩ²éѯÌõ¼þ
Àý:
select top 2 *
from Sys_Material_Type
where (MT_ID not in
    (select top (2*(3-1)) MT_ID from Sys_Material_Type  order by MT_ID))
order by MT_ID
2.·ÖÒ³·½°¸¶þ£º(ÀûÓÃID´óÓÚ¶àÉÙºÍSELECT TOP·ÖÒ³£©
Óï¾äÐÎʽ£º
SELECT TOP ÿҳ¼Ç¼ÊýÁ¿ *
from ±íÃû
WHERE (ID >
          (SELECT MAX(id)
    from (SELECT TOP ÿҳÐÐÊý*Ò³Êý id  from ±í
          ORDER BY id) AS T)
      )
ORDER BY ID
Àý:
SELECT TOP 2 *
from Sys_Material_Type
WHERE (MT_ID >
          (SELECT MAX(MT_ID)
          from (SELECT TOP (2*(3-1)) MT_ID
                from Sys_Material_Type
                ORDER BY MT_ID) AS T))
ORDER BY MT_ID
3.·ÖÒ³·½°¸Èý£º(ÀûÓÃSQLµÄÓαê´æ´¢¹ý³Ì·ÖÒ³)
create  procedure SqlPager
@sqlstr nvarchar(4000), --²éѯ×Ö·û´®
@currentpage int, --µÚNÒ³
@pagesize int --ÿҳÐÐÊý
as
set nocount on
declare @P1 int, --P1ÊÇÓαêµÄid
@rowcount int
exec sp_cursoropen @P1 output,@sqlstr,@scrollopt=1,@ccopt=1, @rowcount=@rowcount output
select ceiling(1.0*@rowcount/@pagesize) as ×ÜÒ³Êý--,@rowcount as ×ÜÐÐÊý,@currentpage as µ±Ç°Ò³
set @currentpage=(@currentpage-1)*@pagesize+1
exec sp_cursorfetch @P1,16,@currentpage,@pagesize
exec sp_cursorclose @P1
set nocount off
4.×ܽá:
ÆäËüµÄ·½°¸£ºÈç¹ûûÓÐÖ÷¼ü£¬¿ÉÒÔÓÃÁÙʱ±í£¬Ò²¿ÉÒÔÓ÷½°¸Èý×ö£¬µ«ÊÇЧÂÊ»áµÍ¡£
½¨ÒéÓÅ»¯µÄʱºò£¬¼ÓÉÏÖ÷¼üºÍË÷Òý£¬²éѯЧÂÊ»áÌá¸ß¡£
ͨ¹ýSQL ²éѯ·ÖÎöÆ÷£¬ÏÔʾ±È½Ï£ºÎҵĽáÂÛÊÇ:
·ÖÒ³·½°¸¶þ£º(ÀûÓÃID´óÓÚ¶àÉÙºÍSELECT TOP·ÖÒ³£©Ð§ÂÊ×î¸ß£¬Ð


Ïà¹ØÎĵµ£º

SQL 2005ÒçÓÃÖ®£º·Ö²ðÁÐÖµ

ÎÊÌâÃèÊö£º
Óбítb, ÈçÏÂ:
id          values
----------- -----------
1           aa,bb
2           aaa,bbb,ccc
Óû°´,·Ö²ðvaluesÁÐ, ·Ö²ðºó½á¹ûÈçÏÂ:
id& ......

½«SQL ServerÊý¾Ý¿âÖмǼµ¼³öΪinsertÓï¾ä

   ÓÐʱÔÚ×ö³ÌÐòʱ£¬²âÊÔʱµÄÊý¾Ý£¬ÒªÄÃÏñÓû§ÑÝʾ£¬Êý¾Ý¿âµÄ¸½¼ÓÊÇ×îÖ±½ÓµÄ°ì·¨£¬µ«Èô´ÓSQL Server 2005תÏò2000µ¼³öÂé·³£¬ÄÚÈÝÒ²¶à£¬Éú³ÉSQLÓï¾äÊÇ×îºÃµÄ°ì·¨£¬Ò²ÊÇÔÚÍøÉÏÕҵŤ¾ß,mssql2µ¼³ö·Ç³£·½±ã£¬µ£ÐÄÎÒÒÔºóÄѵÃÕÒËùÒÔ·ÅÔÚÕâÀÒÔ±¸ºóÓᣠ......

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 ID))
ORDER BY ID
//×Ô¼º»¹¿ÉÒÔ¼ÓÉÏһЩ²éѯÌõ¼þ
Àý:
select top 2 ......

MS SQL 2005 32/64λÏÂÔØ

MS SQL 2005 32/64λÏÂÔØ
thunder://QUFmdHA6Ly9TaGFyZToxNjQzQHd3dy5zb293ZWIubmV0L1NoYXJlL1NlcnZlci9NaWNyb3NvZnQlMjBTUUwlMjBTZXJ2ZXIlMjAyMDA1L1NRTC4yMDA1LmFsbC5jaHMuaXNvWlo=
Microsoft SQL Server 2005 CHN 32λ CD1
ed2k://|file|%5B%E5%BE%AE%E8%BD%AFSQL%E6%9C%8D%E5%8A%A1%E5%99%A82005%E7%AE%80%E4%BD%93% ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ