t-sql between.. and ..误区

时间:2021-12-12 20:12:07

我经常犯的错误。如:写一个分页存储过程

if exsits (select * from sysobjects where name='proce')

dorp procedure proce

go

create procedure proce

@pagezise int,

@pageno int

as

select * from (select row_number() over (order by t1) as rowid) as mm where rowid between (@pageno-1)*@pagesize and @pageno*@pagesize

go

--执行存储过程(该分页只适用于05以上版本)

execute proce 2,2

--得到的结果竟然是三条数据

呵呵,有经验的肯定早就知道问题所在咯,between.. and ..是包含边界值的

不多说了