sqlserver·ÖÒ³´æ´¢¹ý³ÌµÄÓ÷¨
create proc P_QuerySplit
@sqlscript varchar(20), --±íÃû/SQLÓï¾ä
@pageSize int, --ÿҳ¼Ç¼Êý
@pageIndex int, --µ±Ç°Ò³
@totalCount int output, --×ܼǼÊý
@totalPage int output --×ÜÒ³Êý
as
declare @v_sqlscript varchar(20)
declare @v_PageSize int
declare @v_PageIndex int
declare @v_SQL_Count int
declare @v_SQL varchar(4000)
declare @v_StartIndex int
declare @v_EndIndex int
set @v_PageSize=@pageSize
--ÿҳ¼Ç¼Êý
if @v_PageSize=0
set @v_PageSize=1
print @v_pageSize
--²éѯ×ܼǼÊý
select @v_SQL_Count=count(1) from stuInfo
set @totalCount=@v_SQL_Count
print @totalCount
--×ÜÒ³Êý
set @totalPage=ceiling(@totalCount/@v_PageSize)
--µ±Ç°Ò³
if(@pageIndex=1 or @pageIndex<1)
begin
set @pageIndex=1
set @v_PageIndex=@pageIndex
set @v_StartIndex=0
set @v_EndIndex=ceiling(@v_pageIndex*@v_pageSize)
print @pageIndex
end
if @pageIndex>1
begin
set @v_PageIndex=@pageIndex
set @v_StartIndex=ceiling((@v_PageIndex-1)*@v_PageSize)
set @v_EndIndex=ceiling(@v_pageIndex*@v_pageSize)
print @pageIndex
end
set @v_sqlscript=@sqlscript
--µ±Ç°Ò³µÄ¼Ç¼
-- set @v_SQL='select top'+str(@v_PageSize)+' * from '+ @v_sqlscript+
--' where (id>(select max(id) from (select top '+str(@v_startIndex)+' id
--from '+ @v_sqlscript +' order by id) a)) order by id'
--exec (@v_SQL)
set @v_SQL='select * from (select row_number() over(order by id desc) as rownum,
* from '+@v_sqlscript+') as t where t.rownum>'+str(@v_StartIndex)+' a
Ïà¹ØÎĵµ£º
MS SQL Server²éѯÓÅ»¯·½·¨
²éѯËÙ¶ÈÂýµÄÔÒòºÜ¶à£¬³£¼ûÈçϼ¸ÖÖ
1¡¢Ã»ÓÐË÷Òý»òÕßûÓÐÓõ½Ë÷Òý(ÕâÊDzéѯÂý×î³£¼ûµÄÎÊÌ⣬ÊdzÌÐòÉè¼ÆµÄȱÏÝ)
2¡¢I/OÍÌÍÂÁ¿Ð¡£¬ÐγÉÁËÆ¿¾±Ð§Ó¦¡£
& ......
SQLServerÖÐDatetimeÀàÐÍÊý¾ÝµÄ±È½Ï
2009Äê02ÔÂ20ÈÕ ÐÇÆÚÎå 16:40
/* ¶¨Ò忪ʼÈÕÆÚºÍ½áÊøÈÕÆÚ*/
declare @date_a datetime,@date_b datetime
set @date_a='2009-2-10'
set @date_b='2009-2-12'
/* ÔÚÈÕÆÚdate_a(°üº¬) ºÍdate_b(²»°üº¬) Ö®¼ä*/
select * from ut_article where createtime between @ ......
ÉÏһƪ·ÖÒ³ÎÄÕ£¬ÊÇÓÃÓÚmysql£¬ÉÔ΢ÐÞ¸ÄÏ£¬ÓÃÓÚSqlserver2005/2008£¬Ã»ÓÐÒì³£´¦Àí¡£Ã»Óп¼ÂÇÐÔÄܵȡ£
ÏÖ½«´úÂëÌù³ö£¬ÒÔ¹©³õѧÕ߲ο¼£º
×¢£ºÑûÔÂʹÓû·¾³Eclipse 3.4.2+Tomcat 6.18+Sqlserver2005 sp3µ÷ÊԳɹ¦¡£
Ò³ÃæpagelistDemo.jspÄÚÈÝ£º
Code
<%@ page language="java" contentType="text/html; ......
ÔÚSQL Server ÖвåÈëÒ»ÌõÊý¾ÝʹÓÃInsertÓï¾ä£¬µ«ÊÇÈç¹ûÏëÒªÅúÁ¿²åÈëÒ»¶ÑÊý¾ÝµÄ»°£¬Ñ»·Ê¹ÓÃInsert²»½öЧÂʵͣ¬¶øÇһᵼÖÂSQLһϵͳÐÔÄÜÎÊÌâ¡£ÏÂÃæ½éÉÜSQL ServerÖ§³ÖµÄÁ½ÖÖÅúÁ¿Êý¾Ý²åÈë·½·¨£ºBulkºÍ±íÖµ²ÎÊý(Table-Valued Parameters)¡£
ÔËÐÐÏÂÃæµÄ½Å±¾£¬½¨Á¢²âÊÔÊý¾Ý¿âºÍ±íÖµ²ÎÊý¡£
´úÂëÈçÏÂ:
--Create D ......
select
convert(char(4),auth,120)+'Äê'+
substring(convert(char(10),auth,120),6,2)+'ÔÂ'+
substring(convert(char(10),auth,120),9,2)+'ÈÕ',
convert(char(4),appr,120)+'Äê'+
substring(convert(char(10),appr,120),6,2)+'ÔÂ'+
substring(convert(char(10),appr,120),9,2)+'ÈÕ'
from a
ÒÔÉÏ´úÂëʵÏֵĹ¦Ä ......