markpringle (4/19/2015)
It uses a Temp table, but temp tables can't be used in functions, right? I am just not SQL savvy enough to know how to repurpose it.
I see nothing of a temp table in the code. It's just a standard practice for folks like Eirikur and many others to add "USE TempDB" to code to ensure that we cause no damage to a real database whether we use any DDL or not. It's just a habit on forums.
--Jeff Moden
Change is inevitable... Change for the better is not.