Check perfmon to see if maybe the SQL server is just totally out of memory. There should be no logical difference between @table and #table, but the second actually creates a database object while the ...
What the best way to work around this? I have the same SELECT statement but there are different criteria depending on the IF check. Well, if you happen to be using Sql Server you can do that sort of ...