sql分页
--得到总行数
select count(proid) from (select distinct proid from tachecontractid where (empid=@uid or departid=@did) and state>2) as a
--查询出来的时候插入到临时表
select * into #d from tachecontractid a
where id=(select min(id) from (select* from tachecontractid where (departid=@did or empid=@uid) and state>2)
as h where proid=a.proid and proid=h.proid)
--分页
select top(@onepagecout) id,proid,Itemname,Wordname,worddate from #d where id>(
select isnull(max(id),0)from (select top(@onepagecout*@pageindex) id from #d order by id) as h) order by id