bonjour à tous,
je souhaite créer une procedure qui me permet de filtrer la table TotalInvoiced en fonction du champ DateArret.
la procedure doit s'executer chaque 2h. lors du 1er chargement elle charge toutes les données dans la table totalInvoiced, puis que les données compris entre DateArret et DateArret -2h
je suis un peut bloquer.
voici ma procedure
merci de votre aide
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 create procedure @ VarDateArret datetime ; set @VarDateArret=getdate(); --creation d'une table temporaire (TotalInvoice) des montant de facture insert into TotalInvoiced (SELECT DISTINCT ef.entf_EntityFacturationID as EFID , cc.coch_CompanyId as HoldingID , f.fact_FactureDate as DateArret , sum(f.fact_montanthtlc) as SUM_INVOI_montant_fac_lc , sum(f.fact_montanthteuro) as SUM_INVOI_montant_fac_euro , sum(en.enc_Montant) as SUM_ENCAIS_montant_lc , sum(en.enc_Montant_EUR) as SUM_ENCAIS_montant_euro FROM IRTS.dbo.EntityFacturation ef WITH (nolock) INNER JOIN IRTS.dbo.Contrat c WITH (nolock) on Cont_Year = Entf_Year and c.cont_Deleted is null and c.cont_active = 'Y' INNER join IRTS.dbo.ContratChapeau cc WITH (nolock) on cc.coch_ContratChapeauID = c.cont_contratchapeauid and cc.coch_Deleted is NULL and cc.coch_active = 'Y' and CoCh_Type='coch_type.1' LEFT JOIN IRTS.dbo.Facture f WITH (nolock) on e.eche_EcheanceID = f.fact_echeanceid and f.fact_Deleted is null and f.fact_Active = 'Y' LEFT JOIN IRTS.dbo.Encaissement en WITH (nolock) on f.fact_FactureID = en.enc_facture and en.enc_Deleted is null where DateArret between dateadd(hh,-2,@VarDateArret) and @VarDateArret group by ef.entf_EntityFacturationID as EFID , cc.coch_CompanyId as HoldingID , f.fact_FactureDate as DateArret
Partager