This is the one way to achieve your requirement using While loop & Temp table variable,
The sample query is given below,
--: Get the Employees table data & insert this to temp table variable
Declare @TempEmpTbl Table (RowId int identity, EmployeeID int, EmployeeName nvarchar(100), EmployeeStatus int, BasicSalary int);
Insert into @TempEmpTbl Select * from Employees;
--: temp variables
Declare @TempEmpCount Int = (Select Count(RowId) From @TempEmpTbl);
Declare @MinCount Int = 1;
Declare @GetEmpId int;
--: while loop for EmployeePayroll tbl insertion based on Employees data
While(@TempEmpCount >= @MinCount)
Begin
Set @GetEmpId = (Select EmployeeID From @TempEmpTbl Where RowId = @MinCount);
Insert into EmployeePayroll values (0, @GetEmpId,0 ,0 ,0)
Set @MinCount = @MinCount + 1;
End
Note : Suppose the employee record is already there, we can able to update EmployeePayroll records from within this while loop.