可以使用Row_Number 方法,需要多少资料,取多少资料 SELECT ROW,CategoryID,CategoryName,Description FROM (SELECT ROW_NUMBER() OVER(ORDER BY :sortExpression) AS ROW, CategoryID,CategoryName,Description FROM Categories ) AS PageTable WHERE (ROW > @startRowIndex) AND (ROW <= (@maximumRows + @startRowIndex))
SELECT
ROW,CategoryID,CategoryName,Description
FROM
(SELECT
ROW_NUMBER() OVER(ORDER BY :sortExpression) AS ROW,
CategoryID,CategoryName,Description FROM Categories
) AS PageTable
WHERE (ROW > @startRowIndex)
AND (ROW <= (@maximumRows + @startRowIndex))
{
//处理
}
foreach(DataRow row in table.Rows)
{
//代码
}
这是SQL2005的特性吧?如果忽略采用什么数据库呢?
select * top10 from 表名 (具体不记得了)
来查询前10条记录,或者可以查百分之几的数据
select top n * ............ where x not in (select top m * 。)