sql >> Databasteknik >  >> RDS >> Sqlserver

SQL - Hämta data sidvis

Prova den här -

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

Exempel -

EXEC GetAllContacts @searchVal = ''
    ,   @from = 0
    ,   @row_count = 20

EXEC GetAllContacts @searchVal = ''
    ,   @from = 20
    ,   @row_count = 20

EXEC GetAllContacts @searchVal = ''
    ,   @from = 40
    ,   @row_count = 20


  1. CASE i WHERE CLAUSE i MYSQL

  2. PDO - Hämta Assoc i en "while"-loop

  3. Hur kan jag visa tabelldata med Java Stored Procedure?

  4. hur man beräknar saldon i ett bokföringsprogram med postgres fönsterfunktion