I need to run a stored procedure on a bunch of records. The code I have now iterates through the record stored in a temp table. The stored procedure returns a table of records.
I was wondering what I can do to avoid the iteration if anything.
set @counter = 1
set @empnum = null
set @lname = null
set @fname = null
-- get all punches for employees
while exists(select emp_num, lname, fname from #tt_employees where id = @counter)
begin
set @empnum = 0
select @empnum = emp_num, @lname = lname , @fname= fname from #tt_employees where id = @counter
INSERT @tt_hrs
exec PCT_GetEmpTimeSp
empnum
,@d_start_dt
,@d_end_dt
,@pMode = 0
,@pLunchMode = 3
,@pShowdetail = 0
,@pGetAll = 1
set @counter = @counter + 1
end