if@doCount!=0
begin
if@strWhere!=
set@strSQL=selectcount(*)Totalfromwhere+@strWhere
else
set@strSQL=selectcount(*)Totalfrom
end
--以上代码的意义是假如@doCount传送过去的不是0,就实行总数统计。以下的一切代码都是@doCount为0的情形:
else
begin
if@OrderType!=0
begin
set@strTmp=<(selectmin
set@strOrder=orderby[+@fldName+]desc
--假如@OrderType不是0,就实行降序,这句很主要!
end
else
begin
set@strTmp=>(selectmax
set@strOrder=orderby[+@fldName+]asc
end
set@strSQL=selecttop+str(@PageSize)++@strGetFields+from[+@tblName+]+@strOrder
--假如是第一页就实行以上代码,如许会加速实行速率
end
else
begin
set@strSQL=selecttop+str(@PageSize)++@strGetFields+from[
+@tblName+]where[+@fldName+]+@strTmp+([
+@fldName+]) from(selecttop+str((@PageIndex-1)*@PageSize)+[
+@fldName+] from[+@tblName+]+@strOrder+)astblTmp)
+@strOrder
if@strWhere!=
set@strSQL=selecttop+str(@PageSize)++@strGetFields+from[
+@tblName+]where[+@fldName+]+@strTmp+([
+@fldName+])from(selecttop+str((@PageIndex-1)*@PageSize)+[
+@fldName+]from[+@tblName+]where+@strWhere+
+@strOrder+)astblTmp)and+@strWhere++@strOrder
end
end
exec(@strSQL)
--print@strSQL
GO