I have not found a way to do this. I have a large SQL statement that does the following:
- checks for two temp tables, if found deletes them
- Declares local variables
- Sets local variables
- runs SQL statement1 which inserts into #tmp1 (temp table)
- runs SQL statement2 which inserts into #tmp2 (temp table)
- runs SQL statement3 which selects from #tmp1 and #temp2 (temp table) and returns pivot results
Running this in a query window works fine but I'd like to make one function (or something) to do the same.
EDIT1: I seem to be able to call a table function from excel and return those results but I can't call a stored proc from excel, I get an error. The problem with the table function is that I can't delete (drop) tables.