Thanks to all for the answers.
I understood the problem.
I'm rewriting a complex procedure from Sybase in SQL SERVER and in the first there is the possibility of referring to fields created in the statements from the query, while in SQL SERVER I have to do various CTE. The problem was precisely this, in practice the same "dynamic" fields were present in the UPDATE table and therefore I was referring to them without any CTE. After rewriting and reasoning with various CTEs, the values return.
I understood the error by writing an OUTPUT of fields before and after the update. I noticed they entered as NULL, therefore they necessarily had to be the results of the CTEs and not the fields from the table.
SELECT '#anagrafiche - 3310 pre', IdAnagrafica, [FatturatoCalc], [NumeroDipendentiCalc],[TotaleAttivoCalc],[IsRetail] FROM #anagrafiche WHERE IdAnagrafica IN (334402) ORDER BY IdAnagrafica;
CTE 1
CTE 2
CTE 3
UPDATE
SELECT '#anagrafiche - 3500 after', IdAnagrafica, [FatturatoCalc], [NumeroDipendentiCalc],[TotaleAttivoCalc],[IsRetail] FROM #anagrafiche WHERE IdAnagrafica IN (334402) ORDER BY IdAnagrafica;
Thank you all.
ALEN