Just use a second table and join them.
create table #images1images1( id int not null ); create table #images2images2( id int not null ); insert into #images1images1 values(1), (2), (3), (4), (6), (8); insert into #images2images2 values (4), (5), (6); SELECT i2.ID FROM #images2images2 i2 LEFT JOIN #images1images1 i1 ON i1.ID = i2.ID WHERE i1.ID IS NULL