Trying to create a Stored procedure that will give the required no. of records and also the total no. of records in that table.
The '@Query' part gives result when I execute it separately. So there's no problem with that.
Could Someone please check if the syntax is correct, cause I'm not getting at any output
ALTER PROCEDURE GetRecordsByPage
@TotalRows nvarchar(50) output
DECLARE @Query nvarchar(max)
select @TotalRows = 'select count(*) from '+@TableName+' where deleted=0'
select @Query = 'with temp as (select row_number() over (order by '+
@colname+' '+@OrderByClause+') as row, * from '+@tablename+')
select * from temp where row between '+@startIndex+' and '+@EndIndex
execute sp_executesql @Query, @TotalRows output
-- execute GetRecordsByPage 'tblBranch','BranchName', '2', '10'