Ver Mensaje Individual
  #2 (permalink)  
Antiguo 12/07/2007, 11:34
Avatar de iislas
iislas
Colaborador
 
Fecha de Ingreso: julio-2007
Ubicación: Mexico, D.F.
Mensajes: 6.482
Antigüedad: 16 años, 10 meses
Puntos: 180
Re: paginar con sql server

Existe, se llama TOP, aunque no creo que funcione como la de MySQL, para PAGINAR en SQL SERVER:

/* Paginacion de Autores */
CREATE PROCEDURE Autores_Sel
@LastNombre varchar(40) = NULL OUTPUT
AS
SET NOCOUNT ON

-- Seleccione las proximas 5 filas
SELECT TOP 5 WITH TIES *
FROM AUTHORS
WHERE CASE WHEN @LastNombre IS NULL THEN 1
WHEN @LastNombre<au_fname THEN 1
ELSE 0
END=1
ORDER BY AU_FNAME
-- Seleccione el siguiente apellido
SELECT @LastNombre=MAX(AU_FNAME)
FROM ( SELECT TOP 5 au_fname
FROM AUTHORS
WHERE CASE WHEN @LastNombre IS NULL THEN 1
WHEN @LastNombre<au_fname THEN 1
ELSE 0
END=1
ORDER BY AU_FNAME) AS N
GO
/* Fin de Declaracion de Procedimiento */

/* Uso de Procedimiento */
DECLARE @UltimoApellido varchar(40)

EXEC Autores_Sel @UltimoApellido OUTPUT
EXEC Autores_Sel @UltimoApellido OUTPUT
EXEC Autores_Sel @UltimoApellido OUTPUT
EXEC Autores_Sel @UltimoApellido OUTPUT
EXEC Autores_Sel @UltimoApellido OUTPUT
/* Fin de Procedimiento */
=============
Saludos,

Javier Loria