Hello,
I want to create a function with one variable what is a table name. this function has to give me back all the records from the table witch name is given in the variable. The problem is that i've more than 100 table with diffent numbers of collumns and different collumn-names so I cann't declare the temporary table
The next code is working fine but when I try to put this code in a function the next error occurs
"Cannot access temporary tables from within function"
The code i wrote is
EXEC ('SELECT * INTO ##TEMPTABLE FROM [' + @TABL + '] ')
select [ID] from ##TEMPTABLE
drop table ##TEMPTABLE
My question, How can I get this code in a function?