Forum Discussion
Temp table not working in Pipeline Script activities
- 1 year ago
Hi DominilMs,
Thank you for your follow-up.The problem you are facing happens because temporary tables (like #temp) in Microsoft Fabric are only available within the current session. Even though the operations are done in the same Script activity, Fabric may treat them as separate sessions. This causes the #temp table to disappear and gives the error "Invalid object name '#temp'."
Please follow these steps to fix the issue:
-
Use permanent tables instead of temporary ones. Permanent tables are saved in your Lakehouse or Data Warehouse and can be used across different activities. This way, you will not have session-related issues. Permanent tables stay available in all sessions and activities, so the tables won’t disappear.
-
If you don’t want to use permanent tables and your work is in only one Script activity, use table variables (like temp). These variables work only during the execution of that activity.
If you have any more questions, please feel free to ask the Microsoft Fabric community.
Thank you.
-
Hi DominilMs
Each pipeline activity runs in a separate session. Since `#temp` tables are session-scoped, they become inaccessible across activities, causing “Invalid object” errors.
Example: Your `#temp` table fails in Script Activity because the entire pipeline doesn’t share a single session
DECLARE @Temp TABLE` succeeds because it’s batch-scoped, not session-dependent. It remains valid within a single activity’s execution context.
For multi-activity workflows or large data, use physical tables. They persist across sessions and avoid isolation issues.