Error # -2147217900 Invalid column name 'lastpage'.
SQL = declare @pagesize int, @pagenumber int,@firstrow int,@lastrow int select @pagesize = 15,@pagenumber = lastpage select @firstrow = ( @pagenumber - 1) * @pagesize + 1,@lastrow = (@pagenumber - 1) * @pagesize + @pagesize ; with loaddata as (select * from vdiscussions where (1=1) and zona='idn' and discussiontypeid not in (55) and isopen=1 and parentid is null),page as (select *,row_number() over (order by issticky desc,lastupdate desc) as rownumber from loaddata)select * from page where rownumber between @firstrow and @lastrow order by rownumber asc;