Check if the next alternative sample contains useful things:
drop table if exists #tmpSource
drop table if exists #tmpMain
drop table if exists #tmpAutoIDTable
create table #tmpAutoIDTable(RecOrder INT)
create table #tmpSource(ID INT IDENTITY,EmpName VARCHAR(50))
insert into #tmpSource(EmpName) VALUES('Test1')
insert into #tmpSource(EmpName) VALUES('Test2')
insert into #tmpSource(EmpName) VALUES('Test3')
create table #tmpMain(ID INT ,EmpName VARCHAR(50),RecOrder INT)
-- sample existing row:
insert into #tmpMain(ID, EmpName, RecOrder) VALUES(100, 'Test2', 100)
insert #tmpMain (ID, EmpName, RecOrder)
output inserted.RecOrder into #tmpAutoIDTable(RecOrder)
select ID, EmpName, row_number() over (order by EmpName)
from #tmpSource s
where -- filtering source rows:
not exists (select * from #tmpMain where EmpName = s.EmpName)
select * from #tmpMain
select * from #tmpAutoIDTable