Tente este -
CREATE PROCEDURE [dbo].[GetAllContacts]
(
@searchVal VARCHAR(500)
, @from INT
, @row_count INT = 20
)
AS
BEGIN
SELECT DISTINCT (Id) AS Id
, FirstName
, LastName
, address
, Tel_no
FROM tblContact
WHERE FirstName LIKE '%' + @searchVal + '%'
OR LastName LIKE '%' + @searchVal + '%'
ORDER BY LastName
OFFSET @from ROWS
FETCH NEXT @row_count ROWS ONLY;
END
Exemplo -
EXEC GetAllContacts @searchVal = ''
, @from = 0
, @row_count = 20
EXEC GetAllContacts @searchVal = ''
, @from = 20
, @row_count = 20
EXEC GetAllContacts @searchVal = ''
, @from = 40
, @row_count = 20