I need to change the temp table to a CTE in part of my Stored Procedure

159 Views Asked by At
Create table #temp_user (group_id int)
insert #temp_user Exec sp_user_acct XXXX,XX,X

It is working but not a good performance. How can I change it with something below? (CTE)

Create table #temp_user   (group_id int)
;with My_CTE as (select * from #temp_user)
insert into My_CTE Exec sp_user_acct XXXX,XX,X
Select * from My_CTE   
-- it looks like it does the insert but after that:invalid object name  my_cte. 
0

There are 0 best solutions below