we have to do dml in temp table,the CTE is not fit
Moving this to -general only...
Please direct all replies to the list.
You are asking for help but not providing any context for what your requirements are. You are not likely to get good help.
Best case, supply a working function (self contained test case) that does exactly what you need it to do but uses a temporary table and performs badly. Lacking that at least attempt to describe your problem and not just point out that creating temporary tables is expensive.
David J.