If you use a CTE you would not need temp tables, and the optimizer could generate a better plan.
stored proc
Hello,
I have a stored procedure which does the following:
1- filter tables and place data into #table1
2- filter tables and place data into #table2
...
Then at the end of the stored proc, select columns by joining these #tables.
I have several stored procedures which they all have the same steps above, i.e.
1
2
...
and the only difference between the stored procs is where the tables are joined
Question:
Instead of me doing copy/paste of the #tables in steps 1, 2, ...
how can I make this generic so that each stored procedure has mostly the join tables instead of all the creation of #tables, etc.?
Thank you
Developer technologies Transact-SQL
SQL Server Other
1 answer
Sort by: Most helpful
-
Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
2024-12-28T18:37:19.7233333+00:00