Have searched for quite a bit but haven't found any other way than creating a temp table instead of a table variable, but here goes.
I'd like to declare a table variable using dynamic SQL, the reason being that the variable wil be fairly wide (at least a 100 columns). It will be a join of at least 3 tables. Those also will not always be the same 3 tables. So I was thinking I'd use a dynamic sql statement to declare it and then insert into it normally.
The reason this is a table variable and not a temp table is because it needs to persist after a rollback. Basically I'm trying to make a simple script that will move data into table variable and then to whatever kind of temp table after a rollback. Is there any way to do that?