An alternative of using a loop - Insert into Select Statement.
Test Setup SQL:
declare @ABC table(
id int identity(1,1),
companyid int
)
insert into @ABC values(1);
insert into @ABC values(3);
insert into @ABC values(5);
insert into @ABC values(5);
insert into @ABC values(10);
declare @XYZ table(
period varchar(50),
companyid int
)
SQL to insert into @XYZ:
insert into @XYZ
(period, companyid)
select distinct
'Annual', companyid
from @ABC;
What are in @ABC and @XYZ:
select * from @ABC;
select * from @XYZ;