美文网首页
sqlserver分页

sqlserver分页

作者: Albert_d37d | 来源:发表于2021-01-04 15:54 被阅读0次

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

相关文章

网友评论

      本文标题:sqlserver分页

      本文链接:https://www.haomeiwen.com/subject/suevoktx.html