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

SQL Server µÄͨÓ÷ÖÒ³ÏÔʾ´æ´¢¹ý³Ì

ת×Ô£ºhttp://hi.baidu.com/sonichu/blog/item/a494c4ea276f12dad539c9a8.html
½¨Á¢Ò»¸ö Web Ó¦Ó㬷ÖÒ³ä¯ÀÀ¹¦Äܱز»¿ÉÉÙ¡£Õâ¸öÎÊÌâÊÇÊý¾Ý¿â´¦ÀíÖÐÊ®·Ö³£¼ûµÄÎÊÌâ¡£¾­µäµÄÊý¾Ý·ÖÒ³·½·¨ÊÇ:ADO ¼Í¼¼¯·ÖÒ³·¨£¬Ò²¾ÍÊÇÀûÓÃADO×Ô´øµÄ·ÖÒ³¹¦ÄÜ£¨ÀûÓÃÓα꣩À´ÊµÏÖ·ÖÒ³¡£µ«ÕâÖÖ·ÖÒ³·½·¨½öÊÊÓÃÓÚ½ÏСÊý¾ÝÁ¿µÄÇéÐΣ¬ÒòΪÓα걾ÉíÓÐȱµã£ºÓαêÊÇ´æ·ÅÔÚÄÚ´æÖУ¬ºÜ·ÑÄÚ´æ¡£ÓαêÒ»½¨Á¢£¬¾Í½«Ïà¹ØµÄ¼Ç¼Ëøס£¬Ö±µ½È¡ÏûÓαꡣÓαêÌṩÁ˶ÔÌض¨¼¯ºÏÖÐÖðÐÐɨÃèµÄÊֶΣ¬Ò»°ãʹÓÃÓαêÀ´ÖðÐбéÀúÊý¾Ý£¬¸ù¾ÝÈ¡³öÊý¾ÝÌõ¼þµÄ²»Í¬½øÐв»Í¬µÄ²Ù×÷¡£¶ø¶ÔÓÚ¶à±íºÍ´ó±íÖж¨ÒåµÄÓα꣨´óµÄÊý¾Ý¼¯ºÏ£©Ñ­»·ºÜÈÝÒ×ʹ³ÌÐò½øÈëÒ»¸öÂþ³¤µÄµÈ´ýÉõÖÁËÀ»ú¡£
¸üÖØÒªµÄÊÇ£¬¶ÔÓڷdz£´óµÄÊý¾ÝÄ£ÐͶøÑÔ£¬·ÖÒ³¼ìË÷ʱ£¬Èç¹û°´ÕÕ´«Í³µÄÿ´Î¶¼¼ÓÔØÕû¸öÊý¾ÝÔ´µÄ·½·¨ÊǷdz£ÀË·Ñ×ÊÔ´µÄ¡£ÏÖÔÚÁ÷ÐеķÖÒ³·½·¨Ò»°ãÊǼìË÷Ò³Ãæ´óСµÄ¿éÇøµÄÊý¾Ý£¬¶ø·Ç¼ìË÷ËùÓеÄÊý¾Ý£¬È»ºóµ¥²½Ö´Ðе±Ç°ÐС£
×îÔç½ÏºÃµØʵÏÖÕâÖÖ¸ù¾ÝÒ³Ãæ´óСºÍÒ³ÂëÀ´ÌáÈ¡Êý¾ÝµÄ·½·¨´ó¸Å¾ÍÊÇ“¶íÂÞ˹´æ´¢¹ý³Ì”¡£Õâ¸ö´æ´¢¹ý³ÌÓÃÁËÓα꣬ÓÉÓÚÓαêµÄ¾ÖÏÞÐÔ£¬ËùÒÔÕâ¸ö·½·¨²¢Ã»Óеõ½´ó¼ÒµÄÆÕ±éÈÏ¿É¡£
ºóÀ´£¬ÍøÉÏÓÐÈ˸ÄÔìÁË´Ë´æ´¢¹ý³Ì£¬ÏÂÃæµÄ´æ´¢¹ý³Ì¾ÍÊǽáºÏÎÒÃǵİ칫×Ô¶¯»¯ÊµÀýдµÄ·ÖÒ³´æ´¢¹ý³Ì£º
CREATE procedure pagination1
(@pagesize int, --Ò³Ãæ´óС£¬Èçÿҳ´æ´¢20Ìõ¼Ç¼
@pageindex int --µ±Ç°Ò³Âë
)
as
set nocount on
begin
declare @indextable table(id int identity(1,1),nid int) --¶¨Òå±í±äÁ¿
declare @PageLowerBound int --¶¨Òå´ËÒ³µÄµ×Âë
declare @PageUpperBound int --¶¨Òå´ËÒ³µÄ¶¥Âë
set @PageLowerBound=(@pageindex-1)*@pagesize
set @PageUpperBound=@PageLowerBound+@pagesize
set rowcount @PageUpperBound
insert into @indextable(nid) select gid from TGongwen
where fariqi >dateadd(day,-365,getdate()) order by fariqi desc
select O.gid,O.mid,O.title,O.fadanwei,O.fariqi from TGongwen O,@indextable t
           where O.gid=t.nid and t.id>@PageLowerBound
                        and t.id<=@PageUpperBound order by t.id
end
set nocount off
ÒÔÉÏ´æ´¢¹ý³ÌÔËÓÃÁËSQL SERV


Ïà¹ØÎĵµ£º

MS SQL SERVER ²éѯÓÅ»¯

²éѯËÙ¶ÈÂýµÄÔ­ÒòºÜ¶à£¬³£¼ûÈçϼ¸ÖÖ 
        1¡¢Ã»ÓÐË÷Òý»òÕßûÓÐÓõ½Ë÷Òý(ÕâÊDzéѯÂý×î³£¼ûµÄÎÊÌ⣬ÊdzÌÐòÉè¼ÆµÄȱÏÝ) 
        2¡¢I/OÍÌÍÂÁ¿Ð¡£¬ÐγÉÁËÆ¿¾±Ð§Ó¦¡£ 
        3¡¢Ã»Óд´ ......

SQL Server ֪ʶ»ýÀÛ

varcharºÍnvarcharÈçºÎÑ¡Ôñ£º
varcharÔÚSQL ServerÖÐÊDzÉÓõ¥×Ö½ÚÀ´´æ´¢Êý¾ÝµÄ£¬nvarcharÊÇʹÓÃUnicoÀ´´æ´¢Êý¾ÝµÄ¡£ÖÐÎÄ×Ö·û´æ´¢µ½SQL ServerÖлᱣ´æΪÁ½¸ö×Ö½Ú£¨Ò»°ã²ÉÓÃUnico±àÂ룩£¬Ó¢ÎÄ×Ö·û±£´æµ½Êý¾Ý¿âÖУ¬Èç¹û×ֶεÄÀàÐÍΪvarchar£¬ÔòÖ»»áÕ¼ÓÃÒ»¸ö×Ö½Ú£¬¶øÈç¹û×ֶεÄÀàÐÍΪnvarchar£¬Ôò»áÕ¼ÓÃÁ½¸ö×Ö½Ú¡£ËäȻʹÓÃnva ......

SQL²éѯË÷ÒýÓÅ»¯

½¨Á¢Ë÷Òý
£¨Ò»£©ÉîÈëdz³öÀí½âË÷Òý½á¹¹
ʵ¼ÊÉÏ£¬Äú¿ÉÒÔ°ÑË÷ÒýÀí½âΪһÖÖÌØÊâµÄĿ¼¡£Î¢ÈíµÄSQL SERVERÌṩÁËÁ½ÖÖË÷Òý£º¾Û¼¯Ë÷Òý£¨clustered index£¬Ò²³Æ¾ÛÀàË÷Òý¡¢´Ø¼¯Ë÷Òý£©ºÍ·Ç¾Û¼¯Ë÷Òý£¨nonclustered index£¬Ò²³Æ·Ç¾ÛÀàË÷Òý¡¢·Ç´Ø¼¯Ë÷Òý£©¡£ÏÂÃ棬ÎÒÃǾÙÀýÀ´ËµÃ÷һϾۼ¯Ë÷ÒýºÍ·Ç¾Û¼¯Ë÷ÒýµÄÇø±ð£º
Æäʵ£¬ÎÒÃǵĺºÓï ......

SQL Server 2005 ÖеķÖÇø±íºÍË÷Òý(1)


¹ØÓÚ±¾Îı¾ÎÄËùÃè»æµÄ¹¦Äܺͼƻ®ÊÇÏÂÒ»°æ±¾ SQL Server µÄ¿ª·¢·½Ïò¡£ËüÃDz¢·Ç±¾²úÆ·µÄ˵Ã÷Ê飬ÈçÓиü¸Ä£¬Ë¡²»ÁíÐÐ֪ͨ¡£¶ÔÓÚ×îÖÕ²úÆ·ÊÇ·ñ¾ßÓÐÕâЩ¹¦Äܲ»×öÈκÎÃ÷ʾ»ò°µÊ¾µÄ±£Ö¤¡£¶ÔÓÚijЩ¹¦ÄÜ£¬±¾ÎļÙÉè¶ÁÕßÊìϤ SQL Server 2000 ¹¦ÄܺͷþÎñ¡£Óйر³¾°ÐÅÏ¢£¬Çë·ÃÎÊSQL Server ÍøÕ¾»ò SQL Server 2000 ×ÊÔ´¹¤¾ß°ü¡£Õâ²¢²»Ê ......

SQL Server 2005 ÖеķÖÇø±íºÍË÷Òý [2]

·ÖÇøµÄ·¢Õ¹ÀúÊ·
·ÖÇøµÄ¸ÅÄî¶Ô SQL Server À´Ëµ²¢²»Ä°Éú¡£Êµ¼ÊÉÏ£¬´Ë²úÆ·µÄÿ¸ö°æ±¾Öж¼¿ÉÒÔʵÏÖ²»Í¬ÐÎʽµÄ·ÖÇø¡£µ«ÊÇ£¬ÓÉÓÚûÓÐΪÁË°ïÖúÓû§´´½¨ºÍά»¤·ÖÇø¼Ü¹¹¶øרÃÅÉè¼ÆһЩ¹¦ÄÜ£¬Òò´Ë·ÖÇøÒ»Ö±ÊÇÒ»¸öºÜ·±ËöµÄ¹ý³Ì£¬Ã»Óеõ½³ä·ÖµÄÀûÓ᣶øÇÒ£¬Óû§ºÍ¿ª·¢ÈËÔ±¶Ô´Ë¼Ü¹¹´æÔÚÎó½â£¨ÓÉÓÚÆäÊý¾Ý¿âÉè¼Æ±È½Ï¸´ÔÓ£©£¬µÍ¹ÀÁËËüµÄÓÅ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ