代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
MSSQL
】
mssql海量高效分页存储过程
作者:
CSDN
/ 发布于
2012/1/11
/
932
<div><span style="color: rgb(0,0,255)">CREATE</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">PROCEDURE</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">[</span><span style="color: rgb(255,0,0)">dbo</span><span style="color: rgb(255,0,0)">]</span><span style="color: rgb(0,0,0)">.</span><span style="color: rgb(255,0,0)">[</span><span style="color: rgb(255,0,0)">PROC_GetListRecordByPage</span><span style="color: rgb(255,0,0)">]</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@tblName</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">VARCHAR</span><span style="color: rgb(0,0,0)">(</span><span style="color: rgb(128,0,0); font-weight: bold">255</span><span style="color: rgb(0,0,0)">), </span><span style="color: rgb(0,128,128)">--</span><span style="color: rgb(0,128,128)"> 表名</span><span style="color: rgb(0,128,128)"> </span><span style="color: rgb(0,128,0)">@fldName</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">VARCHAR</span><span style="color: rgb(0,0,0)">(</span><span style="color: rgb(128,0,0); font-weight: bold">255</span><span style="color: rgb(0,0,0)">), </span><span style="color: rgb(0,128,128)">--</span><span style="color: rgb(0,128,128)"> 主键字段名</span><span style="color: rgb(0,128,128)"> </span><span style="color: rgb(0,128,0)">@PageSize</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">INT</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,0); font-weight: bold">10</span><span style="color: rgb(0,0,0)">,</span><span style="color: rgb(0,128,128)">--</span><span style="color: rgb(0,128,128)"> 页尺寸</span><span style="color: rgb(0,128,128)"> </span><span style="color: rgb(0,128,0)">@PageIndex</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">INT</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,0); font-weight: bold">1</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,128,128)">--</span><span style="color: rgb(0,128,128)"> 页码</span><span style="color: rgb(0,128,128)"> </span><span style="color: rgb(0,128,0)">@IsReCount</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">INT</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,0); font-weight: bold">0</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,128,128)">--</span><span style="color: rgb(0,128,128)"> 0 返回记录总数; 1只返回数据; 2 都返回</span><span style="color: rgb(0,128,128)"> </span><span style="color: rgb(0,128,0)">@OrderType</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">BIT</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,0); font-weight: bold">0</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,128,128)">--</span><span style="color: rgb(0,128,128)"> 设置排序类型, 非 0 值则降序</span><span style="color: rgb(0,128,128)"> </span><span style="color: rgb(0,128,0)">@strWhere</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">VARCHAR</span><span style="color: rgb(0,0,0)">(</span><span style="color: rgb(128,0,0); font-weight: bold">3000</span><span style="color: rgb(0,0,0)">) </span><span style="color: rgb(128,128,128)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">''</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,128,128)">--</span><span style="color: rgb(0,128,128)"> 查询条件 (注意: 不要加 where)</span><span style="color: rgb(0,128,128)"> </span><span style="color: rgb(0,128,0)">@returnFld</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">VARCHAR</span><span style="color: rgb(0,0,0)">(</span><span style="color: rgb(128,0,0); font-weight: bold">1000</span><span style="color: rgb(0,0,0)">) </span><span style="color: rgb(128,128,128)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">*</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,128)">--</span><span style="color: rgb(0,128,128)">需要返回的列</span><span style="color: rgb(0,128,128)"> </span><span style="color: rgb(0,0,255)">AS</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">BEGIN</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">DECLARE</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@tempSql</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">VARCHAR</span><span style="color: rgb(0,0,0)">(</span><span style="color: rgb(128,0,0); font-weight: bold">6000</span><span style="color: rgb(0,0,0)">) </span><span style="color: rgb(0,128,128)">--</span><span style="color: rgb(0,128,128)"> 临时语句</span><span style="color: rgb(0,128,128)"> </span><span style="color: rgb(0,0,255)">DECLARE</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strSqlAll</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">VARCHAR</span><span style="color: rgb(0,0,0)">(</span><span style="color: rgb(128,0,0); font-weight: bold">6000</span><span style="color: rgb(0,0,0)">) </span><span style="color: rgb(0,128,128)">--</span><span style="color: rgb(0,128,128)"> 主语句</span><span style="color: rgb(0,128,128)"> </span><span style="color: rgb(0,0,255)">DECLARE</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strSqlCnt</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">VARCHAR</span><span style="color: rgb(0,0,0)">(</span><span style="color: rgb(128,0,0); font-weight: bold">400</span><span style="color: rgb(0,0,0)">) </span><span style="color: rgb(0,128,128)">--</span><span style="color: rgb(0,128,128)"> 数据数量</span><span style="color: rgb(0,128,128)"> </span><span style="color: rgb(0,0,255)">DECLARe</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@OrderTypeStr</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">NVARCHAR</span><span style="color: rgb(0,0,0)">(</span><span style="color: rgb(128,0,0); font-weight: bold">20</span><span style="color: rgb(0,0,0)">) </span><span style="color: rgb(0,0,255)">IF</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@OrderType</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">!=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,0); font-weight: bold">0</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">or</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@OrderType</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">is</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">null</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">SET</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@OrderTypeStr</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">DESC</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">ELSE</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">SET</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@OrderTypeStr</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">ASC</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">SET</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@tempSql</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">SELECT ROW_NUMBER() OVER (ORDER BY [</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@fldName</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">] </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@OrderTypeStr</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">) AS rowId,</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@returnFld</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)"> FROM [</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@tblName</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">] </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">IF</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strWhere</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">!=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">''</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">SET</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@tempSql</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@tempSql</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)"> WHERE </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strWhere</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">SET</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strSqlAll</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">SELECT * FROM (</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@tempSql</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">) t WHERE rowId BETWEEN </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,255)">CAST</span><span style="color: rgb(0,0,0)">(((</span><span style="color: rgb(0,128,0)">@PageIndex</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">-</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,0); font-weight: bold">1</span><span style="color: rgb(0,0,0)">) </span><span style="color: rgb(128,128,128)">*</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@PageSize</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,0); font-weight: bold">1</span><span style="color: rgb(0,0,0)">) </span><span style="color: rgb(0,0,255)">AS</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">VARCHAR</span><span style="color: rgb(0,0,0)">) </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)"> AND </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,255)">CAST</span><span style="color: rgb(0,0,0)">((</span><span style="color: rgb(0,128,0)">@PageIndex</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">*</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@PageSize</span><span style="color: rgb(0,0,0)"> ) </span><span style="color: rgb(0,0,255)">AS</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">VARCHAR</span><span style="color: rgb(0,0,0)">); </span><span style="color: rgb(0,128,128)">--</span><span style="color: rgb(0,128,128)">PRINT @strSqlAll</span><span style="color: rgb(0,128,128)"> </span><span style="color: rgb(0,0,255)">EXEC</span><span style="color: rgb(0,0,0)"> (</span><span style="color: rgb(0,128,0)">@strSqlAll</span><span style="color: rgb(0,0,0)">) </span><span style="color: rgb(0,0,255)">IF</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@IsReCount</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">!=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,0); font-weight: bold">1</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">IF</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strWhere</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">!=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">''</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">SET</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strSqlCnt</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">SELECT COUNT(1) AS Total FROM [</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@tblName</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">] WHERE </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strWhere</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">ELSE</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">SET</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strSqlCnt</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">SELECT COUNT(1) AS Total FROM [</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@tblName</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">]</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">EXEC</span><span style="color: rgb(0,0,0)"> (</span><span style="color: rgb(0,128,0)">@strSqlCnt</span><span style="color: rgb(0,0,0)">) </span><span style="color: rgb(0,0,255)">END</span><span style="color: rgb(0,0,0)"> </span></div> <div></div> <div></div> <div><span style="color: rgb(0,0,0)">或者</span></div> <div></div> <div><span style="color: rgb(0,0,0)"><span style="color: rgb(0,0,255)">CREATE</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">PROCEDURE</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">[</span><span style="color: rgb(255,0,0)">dbo</span><span style="color: rgb(255,0,0)">]</span><span style="color: rgb(0,0,0)">.</span><span style="color: rgb(255,0,0)">[</span><span style="color: rgb(255,0,0)">PROC_GetListByPage_Sql2000</span><span style="color: rgb(255,0,0)">]</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@tblName</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">varchar</span><span style="color: rgb(0,0,0)">(</span><span style="color: rgb(128,0,0); font-weight: bold">255</span><span style="color: rgb(0,0,0)">), </span><span style="color: rgb(0,128,128)">--</span><span style="color: rgb(0,128,128)"> 表名</span><span style="color: rgb(0,128,128)"> </span><span style="color: rgb(0,128,0)">@fldName</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">varchar</span><span style="color: rgb(0,0,0)">(</span><span style="color: rgb(128,0,0); font-weight: bold">255</span><span style="color: rgb(0,0,0)">), </span><span style="color: rgb(0,128,128)">--</span><span style="color: rgb(0,128,128)"> 排序字段名 随机为newid()</span><span style="color: rgb(0,128,128)"> </span><span style="color: rgb(0,128,0)">@PageSize</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">int</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,0); font-weight: bold">10</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,128,128)">--</span><span style="color: rgb(0,128,128)"> 页尺寸</span><span style="color: rgb(0,128,128)"> </span><span style="color: rgb(0,128,0)">@PageIndex</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">int</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,0); font-weight: bold">1</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,128,128)">--</span><span style="color: rgb(0,128,128)"> 页码</span><span style="color: rgb(0,128,128)"> </span><span style="color: rgb(0,128,0)">@IsReCount</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">int</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,0); font-weight: bold">0</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,128,128)">--</span><span style="color: rgb(0,128,128)"> 0 返回记录总数; 1只返回数据; 2 都返回</span><span style="color: rgb(0,128,128)"> </span><span style="color: rgb(0,128,0)">@OrderType</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">bit</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,0); font-weight: bold">0</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,128,128)">--</span><span style="color: rgb(0,128,128)"> 设置排序类型, 非 0 值则降序</span><span style="color: rgb(0,128,128)"> </span><span style="color: rgb(0,128,0)">@strWhere</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">varchar</span><span style="color: rgb(0,0,0)">(</span><span style="color: rgb(128,0,0); font-weight: bold">3000</span><span style="color: rgb(0,0,0)">) </span><span style="color: rgb(128,128,128)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">''</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,128,128)">--</span><span style="color: rgb(0,128,128)"> 查询条件 (注意: 不要加 where)</span><span style="color: rgb(0,128,128)"> </span><span style="color: rgb(0,128,0)">@returnFld</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">varchar</span><span style="color: rgb(0,0,0)">(</span><span style="color: rgb(128,0,0); font-weight: bold">1000</span><span style="color: rgb(0,0,0)">) </span><span style="color: rgb(128,128,128)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">*</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,128)">--</span><span style="color: rgb(0,128,128)">需要返回的列</span><span style="color: rgb(0,128,128)"> </span><span style="color: rgb(0,0,255)">AS</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">declare</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strSQL</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">varchar</span><span style="color: rgb(0,0,0)">(</span><span style="color: rgb(128,0,0); font-weight: bold">6000</span><span style="color: rgb(0,0,0)">) </span><span style="color: rgb(0,128,128)">--</span><span style="color: rgb(0,128,128)"> 主语句</span><span style="color: rgb(0,128,128)"> </span><span style="color: rgb(0,0,255)">declare</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strSQL1</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">varchar</span><span style="color: rgb(0,0,0)">(</span><span style="color: rgb(128,0,0); font-weight: bold">6000</span><span style="color: rgb(0,0,0)">) </span><span style="color: rgb(0,128,128)">--</span><span style="color: rgb(0,128,128)"> 主语句</span><span style="color: rgb(0,128,128)"> </span><span style="color: rgb(0,0,255)">declare</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strTmp</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">varchar</span><span style="color: rgb(0,0,0)">(</span><span style="color: rgb(128,0,0); font-weight: bold">2000</span><span style="color: rgb(0,0,0)">) </span><span style="color: rgb(0,128,128)">--</span><span style="color: rgb(0,128,128)"> 临时变量</span><span style="color: rgb(0,128,128)"> </span><span style="color: rgb(0,0,255)">declare</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strOrder</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">varchar</span><span style="color: rgb(0,0,0)">(</span><span style="color: rgb(128,0,0); font-weight: bold">400</span><span style="color: rgb(0,0,0)">) </span><span style="color: rgb(0,128,128)">--</span><span style="color: rgb(0,128,128)"> 排序类型</span><span style="color: rgb(0,128,128)"> </span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@OrderType</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">!=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,0); font-weight: bold">0</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">begin</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">set</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strTmp</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)"><(select min</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">set</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strOrder</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)"> order by </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@fldName</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)"> desc</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">end</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">else</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">begin</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">set</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strTmp</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">>(select max</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">set</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strOrder</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)"> order by </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@fldName</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)"> asc</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">end</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">set</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strSQL</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">select top </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,255)">str</span><span style="color: rgb(0,0,0)">(</span><span style="color: rgb(0,128,0)">@PageSize</span><span style="color: rgb(0,0,0)">) </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@returnFld</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)"> from [</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@tblName</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">] where [</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@fldName</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">]</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strTmp</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">([</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@fldName</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">]) from (select top </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,255)">str</span><span style="color: rgb(0,0,0)">((</span><span style="color: rgb(0,128,0)">@PageIndex</span><span style="color: rgb(128,128,128)">-</span><span style="color: rgb(128,0,0); font-weight: bold">1</span><span style="color: rgb(0,0,0)">)</span><span style="color: rgb(128,128,128)">*</span><span style="color: rgb(0,128,0)">@PageSize</span><span style="color: rgb(0,0,0)">) </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)"> [</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@fldName</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">] from [</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@tblName</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">]</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strOrder</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">) as tblTmp)</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strOrder</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strWhere</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">!=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">''</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">set</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strSQL</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">select top </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,255)">str</span><span style="color: rgb(0,0,0)">(</span><span style="color: rgb(0,128,0)">@PageSize</span><span style="color: rgb(0,0,0)">) </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@returnFld</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)"> from [</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@tblName</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">] where [</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@fldName</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">]</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strTmp</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">([</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@fldName</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">]) from (select top </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,255)">str</span><span style="color: rgb(0,0,0)">((</span><span style="color: rgb(0,128,0)">@PageIndex</span><span style="color: rgb(128,128,128)">-</span><span style="color: rgb(128,0,0); font-weight: bold">1</span><span style="color: rgb(0,0,0)">)</span><span style="color: rgb(128,128,128)">*</span><span style="color: rgb(0,128,0)">@PageSize</span><span style="color: rgb(0,0,0)">) </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)"> [</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@fldName</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">] from [</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@tblName</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">] where </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strWhere</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strOrder</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">) as tblTmp) and </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strWhere</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strOrder</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@PageIndex</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,0); font-weight: bold">1</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">begin</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">set</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strTmp</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">=</span><span style="color: rgb(255,0,0)">''</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strWhere</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">!=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">''</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">set</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strTmp</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)"> where </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strWhere</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">set</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strSQL</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">select top </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,255)">str</span><span style="color: rgb(0,0,0)">(</span><span style="color: rgb(0,128,0)">@PageSize</span><span style="color: rgb(0,0,0)">) </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@returnFld</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)"> from [</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@tblName</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">]</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strTmp</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strOrder</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">end</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,128)">--</span><span style="color: rgb(0,128,128)">print @strSQL</span><span style="color: rgb(0,128,128)"> </span><span style="color: rgb(0,0,255)">exec</span><span style="color: rgb(0,0,0)"> (</span><span style="color: rgb(0,128,0)">@strSQL</span><span style="color: rgb(0,0,0)">) </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@IsReCount</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">!=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,0); font-weight: bold">1</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strWhere</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">!=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">''</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">set</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strSQL1</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">select count(*) as Total from [</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@tblName</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">]</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)"> where </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strWhere</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">else</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">set</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@strSQL1</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">select count(*) as Total from [</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">@tblName</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(255,0,0)">]</span><span style="color: rgb(255,0,0)">'</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">exec</span><span style="color: rgb(0,0,0)"> (</span><span style="color: rgb(0,128,0)">@strSQL1</span><span style="color: rgb(0,0,0)">) </span></span></div>
试试其它关键字
高效分页存储过程
同语言下
.
SQL查询 多列合并成一行用逗号隔开
.
查看存储过程修改时间,最近执行时间
.
设置手动批量删除数据库相关进程
.
获取某个表中特定字段的所有字符串形式
.
SQL 如何去除重复的字符串
.
怎么去掉一个字段中的重复数据
.
String 去除空格 回车 换行 水平制表符
.
SQL查询和替换含有回车,空格,TAB
.
SQL SERVER 查询每日新增用户数量、次留数量
.
判断两个字符串是否存在相同的内容
可能有用的
.
C#实现的html内容截取
.
List 切割成几份 工具类
.
SQL查询 多列合并成一行用逗号隔开
.
一行一行读取txt的内容
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
Java PDF转换成图片并输出给前台展示
.
网站后台修改图片尺寸代码
.
处理大图片在缩略图时的展示
CSDN
贡献的其它代码
(
27
)
.
xml操作类
.
完全无组件,不用调用Excel.exe 导出数据到Excel
.
DropDownList手动构造一个下拉树形
.
判断是否低于IE6的版本
.
javascript 鼠标拖拉画图
.
取汉字首字母
.
字符串格式化通用类
.
mssql海量高效分页存储过程
.
.net 获取远程IP 得到省市
.
javascript 模仿windows拖动 封装类
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3