ALTER PROCEDURE [dbo].[APPROVED_KM]-- 20,0,15,4 ( @HUB_ID INT, @Pageindex int, @pageSize int, @totalrows int output ) AS BEGIN
; with cte as ( --all the codes are written inside the cte which i am not showing here )
select @totalrows=count(rownum) from cte
select * from cte order by address_id OFFSET ((@Pageindex+1)-1)*@pageSize ROWS FETCH NEXT @pageSize ROWS ONLY
select * into #temp1 from cte select @totalrows=count(rownum) from #temp1 print @totalrows select * from #temp1 order by address_id OFFSET ((@Pageindex+1)-1)*@pageSize ROWS FETCH NEXT @pageSize ROWS ONLY
;WITH CTE AS ( --SELECT ... ) INSERT INTO @tmp (DestField1, DestField2, ...) SELECT (CteField1, CteField2, ...) FROM CTE SELECT @total = COUNT(*) FROM @tmp --and so on...
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)