• Why does the table have to be created on the fly? You know the output of the proc already, so create the temp table using that basis.

    If you say you want one routine for all procs, you're being lazy. Create routines for each proc that needs this.