DROP PROC REPORTE_TURNOS_SIDE_PROC
GO
CREATE PROC REPORTE_TURNOS_SIDE_PROC
( 	@SITEID		UD_IDSITE,
	@DATEPROCEINI	char(8),
	@DATEPROCEFIN	char(8)
)
AS
BEGIN
	SELECT OP_TURNVSSIDE.SITEID,SITE.NAME,DATEPROCE,DATESALES,NUMBERTURN,OP_TURNVSSIDE.SALESPERID,SALESPERNAME,SIDE,OP_TURNVSSIDE.STATUS,SALESPERIDOLD
	FROM (OP_TURNVSSIDE JOIN SITE ON
	OP_TURNVSSIDE.SITEID=SITE.SITEID) JOIN OP_SALESPERSON ON
	OP_TURNVSSIDE.SALESPERID=OP_SALESPERSON.SALESPERID
	WHERE DATEPROCE>=cast(@DATEPROCEINI as smalldatetime) AND DATEPROCE<=cast(@DATEPROCEFIN as smalldatetime)  AND OP_TURNVSSIDE.SITEID=@SITEID

END 


REPORTE_TURNOS_SIDE_PROC '57','20030101','20030101'