SQL·ÖÒ³¼¼Êõ
±¾ÎÄÀ´×Ô£ºhttp://niunan.javaeye.com/blog/264197
±È½ÏÍòÄܵķÖÒ³£º
select top ÿҳÏÔʾµÄ¼Ç¼Êý * from topic where id not in
(select top £¨µ±Ç°µÄÒ³Êý-1£©×ÿҳÏÔʾµÄ¼Ç¼Êý id from topic order by id desc)
order by id desc
ÐèҪעÒâµÄÊÇÔÚaccessÖв»ÄÜÊÇtop 0£¬ËùÒÔÈç¹ûÊý¾ÝÖ»ÓÐÒ»Ò³µÄ»°¾ÍµÃ×öÅжÏÁË¡£¡£
SQL2005ÖеķÖÒ³´úÂë:
with temptbl as (
SELECT ROW_NUMBER() OVER (ORDER BY id desc)AS Row,
...
)
SELECT * from temptbl where Row between @startIndex and @endIndex
·ÖÒ³´æ´¢¹ý³Ì:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: Å£ëî
-- Create date: 2009-07-22 12:41
-- Description: ·ÖÒ³£¬Óõ½ÁËROW_NUMBER()
-- =============================================
ALTER PROCEDURE [dbo].[proc_ShowPage]
@tblName varchar(255), -- ±íÃû
@strGetFields varchar(1000) = '*', -- ÐèÒª·µ»ØµÄÁУ¬Ä¬ÈÏ*
@strOrder varchar(255)='', -- ÅÅÐòµÄ×Ö¶ÎÃû£¬±ØÌî
@strOrderType varchar(10)='ASC', -- ÅÅÐòµÄ·½Ê½,ĬÈÏASC
@PageSize int = 10, -- Ò³³ß´ç,ĬÈÏ10
@PageIndex int = 1, -- Ò³Âë,Ä
Ïà¹ØÎĵµ£º
sqlÈÕÆÚº¯Êý(ת)
[ 2007-8-23 16:33:00 | By: ²½ ]1.Ò»¸öÔµÚÒ»ÌìµÄ
Select DATEADD(mm, DATEDIFF(mm,0,getdate()), 0)
2.±¾ÖܵÄÐÇÆÚÒ»
Select DATEADD(wk, DATEDIFF(wk,0,getdate()), 0)
3.Ò»ÄêµÄµÚÒ»Ìì
Select DATEADD(yy, DATEDIFF(yy,0,getdate()), 0)
4.¼¾¶ÈµÄµÚÒ»Ìì
Select DATEADD(qq, DATEDIFF(qq,0,getdat ......
´æ´¢¹ý³Ì
==========================================================================
==========================================================================
¡¾ÑµÁ·15.1¡¿ ´´½¨Ò»¸öÏÔʾ¹ÍÔ±×ÜÈËÊýµÄ´æ´¢¹ý³Ì¡£
²½Öè1£ºµÇ¼SCOTTÕË»§(»òѧÉú¸öÈËÕË»§)¡£
²½Öè2£º ......
´Ó²©¿ÍÔ°Öп´µ½Ò»ÆªÎÄÕ£¬½éÉÜ´óÈí¼þ¹«Ë¾ÃæÊÔʱ³£³£»á³öµÄÁ½µÀSQLÌ⣨¼û¸½Â¼£©¡£
ÎÒ¾õµÃÊÜÒæºÜ¶à£¬ÔÚ´Ë֮ǰ£¬ÎÒÒ»Ö±¾õµÃ£¬SQL2008ËƺõÌṩÁËÕâ·½ÃæµÄÖ§³Ö£¬µ«¸üµÍµÄ°æ±¾£¬°üÀ¨2005£¬·ÇÓαê×ö²»³öÀ´£¨Ë®Æ½¹»²Ë£©¡£×ܽáÐĵÃÈçÏ£º
1¡¢ Ç¿´óµÄgroup by
1 select stdname,
2 isnull( ......
ÎÄÕµ¼º½ SQL Server 2005 ѧϰ±Ê¼ÇϵÁÐÎÄÕµ¼º½
ÔÚSQl 2005 For XMl ¼òµ¥²éѯ(Raw£¬Auto£¬Pathģʽ)(1) ÀïÎÒÃÇ˵Á˹ØÓÚPath£¬RawºÍAutoģʽµÄÓ÷¨£¬ÆäʵÀïÃæ²»½ö½ö ÊÇÕâЩ¼òµ¥µÄ²Ù×÷£¬»¹ÓÐһЩÆäËüµÄÌØÐÔ£¬±ÈÈç˵Type»òOpenXml·½·¨£¬sp_xml_preparedocument´æ´¢¹ý³Ì µÈÕâЩÔö¼ÓµÄ¶«¶«£¬ÎÒÃÇÀ´Ò» ......
select pcode from (
select h.k,h.d,h.m,h.u,l.areacode,
l.areacode||substr(h.u,4,length(h.u))||h.k pcode
from(
&nb ......