I recently inherited a database on which one of the tables has the primary key composed of encoded values (Part1*1000 + Part2).
I normalized that column, but I cannot ch
The best way is building a temp table with all IDs
Than make a left join.
declare @maxId int
select @maxId = max(YOUR_COLUMN_ID) from YOUR_TABLE_HERE
declare @t table (id int)
declare @i int
set @i = 1
while @i <= @maxId
begin
insert into @t values (@i)
set @i = @i +1
end
select t.id
from @t t
left join YOUR_TABLE_HERE x on x.YOUR_COLUMN_ID = t.id
where x.YOUR_COLUMN_ID is null