Currently in a simple form i have the following declared table in code:
declare @FileIDs as table
(
ID int not null
)
and i can fill it up e.g. manually like this:
insert into
@FileIDs
values
(1)
insert into
@FileIDs
values
(2)
insert into
@FileIDs
values
(3)
Also i have another table called Files and i like to select only those items, that have the same ID.
So I’ve tried the following approaches, but both fail:
select
*
from
Files
where
ID in
(
@FileIDs
)
select
*
from
Files
inner join @FileIDs
on Files.ID = @FileIDs.ID
Any ideas on how i can solve this problem?
You can do either
In the first query your syntax was incorrect. You had to have
And in the second you need to assign an alias to the table variable.