Si consideri il seguente codice:TSQL Scrittura in una tabella temporanea da SQL dinamico
SET @SQL1 = 'SELECT * INTO #temp WHERE ...'
exec(@SQL1)
SELECT * from #temp (this line throws an error that #temp doesn't exist)
A quanto pare questo è perché il comando exec gira fuori una sessione separata e #temp è locale per quella sessione. Posso usare una tabella temporanea globale ## temp, ma poi devo inventare uno schema di denominazione per evitare le collisioni. Cosa raccomandate tutti?
Potrebbe causare problemi nell'ambiente multiutente – Madhivanan
@Madhivanan Quali problemi? – gotqn