How can I use a table variable while executing a command string?
DECLARE @FileIDs TABLE
(
File_ID int
)
insert into @FileIDs select ID from Files where Name like '%bla%';
DECLARE @testquery as varchar(max);
set @testquery = 'select * from @FileIDs';
exec(@testquery);
returns the following error
Msg 1087, Level 15, State 2, Line 1 Must declare the table variable "@FileIDs".