获取前N条记录的存储过程
1、利用 rowcount:
create proc procNum
(
@page INT
)
as
SET ROWCOUNT @PAGE
SELECT * FROM MEMBERS
GO
2、利用拼接字符串:
CREATE proc procNum
(
@page nvarchar(10)
)
as
declare @sqlStr nvarchar(100)
set @sqlStr='select top ' + @page + ' * from members'
exec (@sqlStr)
GO