1 of 1 people found this helpful
The reason why the procedure fails is that you didn't set nocount on.
There is a long discussion in this thread.
You should get a good performance without a temp table in your scenario since Tableau already creates a temp table for you then queries that table. With your procedure, Tableau will still get the results from the second select statement and create another temp table and then query that.