Welcome Guest, Not a member yet? Register   Sign In
mssql pagination
#6

[eluser]barbazul[/eluser]
I' reading through the example page and found the following example.
I'm not an expert in MSSQL but it looks as if they are using an order by clause without any trouble.
Maybe there is a way to accomplish this after all

this is the kind of thing for which I hate working with mssql

----------------------------------------------------------

Estoy leyendo la pagina del link y encontre este ejemplo.
Ahora, yo no soy un experto en MSSQL pero parece que en el ejemplo usan un order by sin problemas

Este es el tipo de cosas por las que odio trabajar con mssql

(traduje el codigo al ingles para entendimiento general)

----------------------------------------------------------

Code:
CREATE PROCEDURE GetContactsPage
    @PageSize int,
    @PageNumber int
AS
    DECLARE @Handle int
    DECLARE @CursorType  int
    SET @CursorType=4 -- Forward only
    DECLARE @LockType int
    SET @LockType =1 -- Read only
    DECLARE @Query nvarchar(4000)
    SET @Query = N'SELECT ContactID, LastName, FirstName, EmailAddress, Phone
                      FROM Person.Contact ORDER BY LastName, ContactID'
    DECLARE @rowcount  int -- will always be -1
    EXEC sp_cursoropen @Handle OUTPUT, @Query, @CursorType OUTPUT, @LockType OUTPUT, @rowcount OUTPUT

    DECLARE @DisplacementType int
    SET @DisplacementType = 32 -- Relative
    DECLARE @FirstRecord int
    SET @FirstRecord = @PageSize * @PageNumber + 1
    EXEC sp_cursorfetch @Handle, @DisplacementType, @FirstRecord , @PageSize

    EXEC sp_cursorclose @Handle


Messages In This Thread
mssql pagination - by El Forum - 07-26-2007, 04:59 PM
mssql pagination - by El Forum - 09-24-2007, 03:44 PM
mssql pagination - by El Forum - 09-24-2007, 05:13 PM
mssql pagination - by El Forum - 09-24-2007, 07:23 PM
mssql pagination - by El Forum - 09-25-2007, 02:48 PM
mssql pagination - by El Forum - 09-29-2007, 02:23 PM
mssql pagination - by El Forum - 09-29-2007, 10:47 PM
mssql pagination - by El Forum - 08-20-2008, 06:38 AM
mssql pagination - by El Forum - 03-04-2011, 02:16 AM



Theme © iAndrew 2016 - Forum software by © MyBB