I am trying to load stored procedure result set into a temp table, but data is not loading into the temp table. The stored procedure results are not stored into the temp table. It is showing "0 rows affected".
Example #1:
EXEC dbo.emp
(10 row(s) affected)
Example #@:
insert into #tempemp
EXEC dbo.emp
(0 row(s) affected)
10 rows are not loaded into the temp table.
I tried like this:
insert into #tempemp
EXEC sp_executesql @tsql = N'EXEC(''EXEC dbo.emp '')
with RESULT SETS
(
(
EMPID varchar(100)
,EMPName VARCHAR(100)
,EMPCode VARCHAR(7)
,EMPNumber VARCHAR(20)
,[STATE] VARCHAR(50)
,City VARCHAR(50)
,Zip VARCHAR(20)
,CustomerTypeName VARCHAR(100)
,StatusCD VARCHAR(50)
,FilterCode VARCHAR(100)
)
)'
but I only get an error :
Msg 11536, Level 16, State 1, Line 1
EXECUTE statement failed because its WITH RESULT SETS clause specified 1 result set(s), but the statement only sent 0 result set(s) at run time.
but stored procedure is returning only one result set.
Can anyone help with this?
Thanks.