标签:
每次传SQL进行分页,包含很多字段的话,大数据量通信还是会有些影响的。
由此引入存储过程的有点:
A、 存储过程允许标准组件式编程
B、 存储过程能够实现较快的执行速度
C、 存储过程减轻网络流量
D、 存储过程可被作为一种安全机制来充分利用
系统管理员可以对执行的某一个存储过程进行权限限制,从而能够实现对某些数据访问的限制,避免非授权用户对数据的访问,保证数据的安全。
下边就是这解决我们的分页问题:
---存储过程、仍然使用row_number完成分页 if (object_id(‘pro_page‘, ‘P‘) is not null) drop proc proc_cursor go create proc pro_page @startIndex int, @endIndex int as select count(*) from product ; select * from ( select row_number() over(order by pid) as rowId, * from product ) temp where temp.rowId between @startIndex and @endIndex go --drop proc pro_page exec pro_page 1, 4
标签:
原文地址:http://www.cnblogs.com/ericli-ericli/p/5586954.html