Contradiction:
Nothing comes without caveats! You cannot use Table Variables in the following situations:
select xxx into @table_variable
or
(here) insert into @table_variable select * from myTable
For example if you want to get the output of a Stored Procedure into a table variable, you cannot do so without circumvention. Here is a sample piece of code which gets the output of a Stored Procedure in to a temporary variable. The only way to get the output of a stored procedure into a table variable is by using an intermediary table, for example using a temporary table.
set nocount oncreate table #sp_depends ( t1nchar(128), t2nchar(128) )insert into #sp_depends execute sp_depends myTabledeclare @t1 table (ta varchar(200), tb varchar(200))
(here) insert into @t1 select * from #sp_depends
drop table #sp_dependsselect * from @t1
Don't just give the hungry man a fish, teach him how to catch it as well.
the sqlist