Guest User

Untitled

a guest
Aug 21st, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. set ANSI_NULLS ON
  2. set QUOTED_IDENTIFIER ON
  3. go
  4.  
  5.  
  6. ALTER Procedure [dbo].[planchev_registrados_obtener](
  7. @filtrarPorRecibirCuota bit= null,
  8. @soloConCuponesPendientes bit= null
  9. )
  10. as
  11. begin
  12.  
  13. /* VARIABLES */
  14. Declare @FechaArg DateTime
  15. /* la fecha actual de argentina es la UTC - 3 */
  16. Select @FechaArg = dateAdd(hour, -3, getutcdate())
  17.  
  18. select registrados.*
  19. from planchev_registrados registrados
  20. where
  21. ( isnull(@filtrarPorRecibirCuota, 0)= 0
  22. or ( isnull(@filtrarPorRecibirCuota, 0)<> 0
  23. and isnull(registrados.recibir_cuota, 0)<> 0
  24. )
  25. )
  26. and ( isnull(@soloConCuponesPendientes, 0)= 0
  27. or ( isnull(@soloConCuponesPendientes, 0)<> 0
  28. and exists ( select 1
  29. from planChevCupones cupones
  30. inner join planChevCodigosBarra codigos on cupones.idCupon= codigos.idCupon
  31. where datediff(day, @FechaArg, codigos.FechaValidezPago) > 0
  32. )
  33. )
  34. )
  35. end
Add Comment
Please, Sign In to add comment