insert into VCLib.T_GEN_NUMBERS (GenNumbersID, EntityID, NumberName, NextNumber)
select newid(), gen.EntityID, gen.NumberName, max(gen.NextNumber) as NextNumber
from DARS.T_GEN_NUMBERS gen
join VCLib.T_ENTITIES ent on ent.EntityID = gen.EntityID
where ent.[Schema] in ('DARS') 
group by gen.NumberName, gen.EntityID