/*On vire ces vues temporaires des DOA*/
--drop view if exists TEMP_PREPARE
--drop view if exists TEMP_PREPARE2

/*MAJ DOC_DATEMODI spec */
WITH cte1 (T,N,D) AS (select max(EVE_TYPE_TRANSACTION),max(EVE_NUMERO_DOCUMENT) ,max(EVE_DATE_CREATION)  from <PREFIXE_DW>EVENEMENTS group by EVE_TYPE_TRANSACTION,EVE_NUMERO_DOCUMENT)
update doc set DOC_DATEMODI= CONVERT(VARCHAR, D, 112) 
	from <PREFIXE_DW>DOCUMENTS doc, cte1 c where DOC_TYPE_TRANSACTION=T and DOC_NUMERO_DOC=N
	and  DOC_DATEMODI<> CONVERT(VARCHAR, D, 112) 