SELECT TOP @PageSize @QueryFields
FROM @TableName
WHERE @Condition
-- ORDER BY @PrimaryKey ASC |
SELECT TOP @PageSize @QueryFields
FROM @TableName
WHERE @PrimaryKey > (
SELECT MAX(@PrimaryKey) FROM (
SELECT TOP @PageSize*@PageIndex @PrimaryKey
FROM @TableName
WHERE @Condition
-- ORDER BY @PrimaryKey ASC
) TableA
) WHERE @Condition
-- ORDER BY @PrimaryKey ASC |
SELECT * FROM (
SELECT TOP @PageSize @QueryFields
FROM @TableName
WHERE @PrimaryKey < (
SELECT MIN(@PrimaryKey) FROM (
SELECT TOP (@RecordCount-@PageSize*(@PageIndex+1)) @PrimaryKey
FROM @TableName
WHERE @Condition
ORDER BY @PrimaryKey DESC
) TableA
) WHERE @Condition
ORDER BY @PrimaryKey DESC
) TableB
ORDER BY @PrimaryKey ASC |
SELECT * FROM (
SELECT TOP (@RecordCount-@PageSize*@LastIndex) @QueryFields
FROM @TableName
WHERE @Condition
ORDER BY @PrimaryKey DESC
) TableA
ORDER BY @PrimaryKey ASC |
本文地址:http://com.8s8s.com/it/it45097.htm