日期:2014-05-17  浏览次数:20684 次

求一条sql语句??
在mysql里面的sql语句是这样的,但是在sqlserver2008里面没有limit这个关键字

String sql = "select * from stu where 1 = 1 ";
sql += " order by stu limit "+((pageIndex-1)*pageSize)+","+pageSize+"";

求在sqlserver里面这条sql语句改怎么写

------解决方案--------------------
String sql = "select top '"+pageSize+"' from stu where id not in(select top '"+pageSize*(pageIndex-1)+" from stu')";
------解决方案--------------------
"select top "+每页显示数+" * from table as t1 where (ID not in (select top "+当前页数+" t2.任务序号 from table as t2 order by ID desc))order by ID desc";

------解决方案--------------------
String sql = "select top "+pageSize+" * from stu where id not in(select top "+pageSize*(pageIndex-1)+" id from stu)";