I am trying to achieve this
WHILE @@FETCH_STATUS = 0
BEGIN
INSERT INTO #TRSupervisors
EXEC [stpEmployee_getExpiryDateSupervisors] '0000912479', '100', @TRplant, 'ILOD', 1, 0
FETCH NEXT FROM TRcurPlant INTO @TRplant
END
On execution I am getting error message which says.
Msg 8164, Level 16, State 1, Procedure stpEmployee_getExpiryDateSupervisors, Line 87
An INSERT EXEC statement cannot be nested.
If I execute it without insert statement, like this:
WHILE @@FETCH_STATUS = 0
BEGIN
--insert into #TRSupervisors
EXEC [stpEmployee_getExpiryDateSupervisors] '0000912479', '100', @TRplant, 'ILOD', 1, 0
FETCH NEXT FROM TRcurPlant INTO @TRplant
END
I'm able to get the desired output.
Please suggest a way to save the output into a temp table.