日期:2014-05-17 浏览次数:20606 次
create proc displayN(@n int)
as
set nocount on
declare @num int
select @num=count(*) from xsqk
if @n>@num
begin
RAISERROR ('n已经超过总记录数.',1,1)
return
end
select *
from (
select *,rn=row_number() over(partition by getdate() order by getdate() from dept
)t
where rn =@n
go
create proc displayNM(@n int,@m int)
as
set nocount on
declare @num int
select *
from (
select *,rn=row_number() over(partition by getdate() order by getdate() from dept
)t
where rn between @n and @m
go
--测试
exec displayN 1
exec displayNM 1,5