Advertisement
EmilianoRoldanR

Ver que dias no se subieron ventas a Analytics y subirlas manualmente

Apr 23rd, 2021
4,277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 1.43 KB | None | 0 0
  1. --primero debes de validar las fechas q se han realizando las operaciones de envio de analytics
  2. SELECT * FROM indicator_date_relation ORDER BY date_relation DESC
  3.  
  4. --para validar si se realizaron los proceso de envio... es id_relation con el Id de la tabla indicator_date_relation
  5. SELECT * FROM indicator_data_operation WHERE id_relation='5b966fb1f821aa6ab284cb69b13a4e49'
  6.  
  7. --ya validando q si no se han creado los registros de envio
  8. --se utiliza este comando que solo se cambia la fecha
  9. --SCRIPT PARA GENERAR LOS DATOS FALTANTES QUE NO SE HALLAN ENVIADO
  10. DECLARE @id_relation VARCHAR(32)
  11. DECLARE @sqlCommand NVARCHAR(MAX)
  12. DECLARE @date_ticket DATE ='2021-04-11'
  13. SET @id_relation=(SELECT [dbo].[indicator_returnIdGeneratedDate](@date_ticket))
  14. IF NOT EXISTS(SELECT TOP(1)IdRelation FROM indicator_date_relation WITH (NOLOCK) WHERE IdRelation=@id_relation)
  15. BEGIN  
  16.     PRINT 'GUARDANDO ID RELATION'
  17.     SET @sqlCommand=' INSERT INTO indicator_date_relation(IdRelation,date_relation) VALUES('+CHAR(39)+@id_relation+CHAR(39)+','+CHAR(39)+CONVERT(VARCHAR(MAX),@date_ticket)+CHAR(39)+')'
  18.     PRINT @sqlCommand
  19.     EXEC (@sqlCommand)
  20.     EXEC [dbo].[indicator_create_send_data] @date_ticket,'0','A'
  21.     EXEC [dbo].[indicator_execute_send_data] @date_ticket
  22. END
  23. ELSE
  24. BEGIN
  25.     PRINT 'ID RELATION, SI EXISTE, SOLO EJECUTO LOS COMANDO PARA GENERAR EL DIA'
  26.     EXEC [dbo].[indicator_create_send_data] @date_ticket,'0','A'
  27.     EXEC [dbo].[indicator_execute_send_data] @date_ticket
  28. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement