I need to enchance the following function:
create function dbo.GetCustomersByRegion (@PageNo integer, @PageSize integer)
returns table
as
return (
select *
from (select row_number() over(order by customerid) as row_num, *
from customers) a
where row_num >= @PageSize * @PageNo and
row_num < @PageSize * (@PageNo + 1)
)
How can I replace customers with a select sql statement and customerid with a parameter in the above function They are literals themselves and seem cannot be replaced with parameters.
Or I must resort to stored procedure
Regards,
Ricky