首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

MS SQL分页有关问题

2012-03-09 
MS SQL分页问题selecttop 20 nEquipmentId,strEntName,strEquipmentType,strRegCode,strProduceCorp,strEq

MS SQL分页问题
select top 20 nEquipmentId,strEntName,strEquipmentType,strRegCode,strProduceCorp,strEquipmentModel,strEquipmentNumber,strEntEmail,strEquipmentDate,strMaxYear,strFlowName,nFlowState 
from t_qyequipment 
where nEquipmentId not in
(select top 360 nEquipmentId from t_qyequipment Where nFlowState>100 and 1=1 order by nFlowState ASC ) and nFlowState>100
ORDER BY nFlowState ASC 

这是拼接好的SQL 
在分到17页之后后面的记录就会跟之前一页的记录相同
到底是什么问题?

[解决办法]
select top 20 nEquipmentId,strEntName,strEquipmentType,strRegCode,strProduceCorp,strEquipmentModel,strEquipmentNumber,strEntEmail,strEquipmentDate,strMaxYear,strFlowName,nFlowState
from t_qyequipment
where nEquipmentId not in
(select top 380 nEquipmentId from t_qyequipment Where nFlowState>100 and 1=1 order by nFlowState ASC ) and nFlowState>100
ORDER BY nFlowState ASC

红色部分的排序字段用主键看看!

热点排行