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 ...
I've said it before and I'll say it again: If you want to speed up your application, don't look at your code, look at your data access. The two slowest things you can do in application development are ...