sqlserver分页
2021-01-04 本文已影响0人
Albert_d37d
if OBJECT_ID('Person','U') is not null
drop table Person;
create table Person
(
nickname varchar(128)
);
declare @i int;
set @i = 0;
while @i < 5
begin
insert into Person(nickname) values('jack' + convert(varchar(4),@i));
select @i = @i + 1;
end
--分页语句
select * from (select *, ROW_NUMBER() OVER(Order by nickname ) AS RowId from Person) as b where RowId between 1 and 4