DROP PROCEDURE OP_ListarTickets
GO 
CREATE PROCEDURE OP_ListarTickets
(@SITEID	UD_IDSITE,
 @NBRDOCUMENTINI  UD_CORRELATIVOS,
 @NBRDOCUMENTFIN  UD_CORRELATIVOS
) 
as
BEGIN
	DECLARE @DOCTYPEIDTICKET UD_DOCTYPEID
	SET @DOCTYPEIDTICKET =(SELECT DOCTYPEIDTICKET FROM OP_SETUP)

	SELECT S.DOCTYPEID,S.NBRDOCUMENT,S.SITEID
	FROM OP_SALES AS S
	WHERE DOCTYPEID=@DOCTYPEIDTICKET AND S.SITEID=@SITEID AND S.NBRDOCUMENT BETWEEN @NBRDOCUMENTINI AND @NBRDOCUMENTFIN
	ORDER BY S.NBRDOCUMENT
END

