I got a nested stored procedure to get some report from third party application to my local application. The stored procedure is working as expected and returns the result, when I am trying to get it temp table showing the below error.
The metadata could not be determined because statement 'INSERT INTO [#TblSrc] EXEC [prcGetReportList] @Src' in procedure 'sysGetBalanceBill' uses a temp table.
This procedure exists in a third-party application.
My stored procedure looks like this:
ALTER PROCEDURE [dbo].[usrGetBalanceBystore]
@Customer VARCHAR(100),
@Store VARCHAR(100)
AS
BEGIN
IF NOT EXISTS (SELECT * FROM tblRpBase
WHERE idrpTable = '2B1A7150-FD1B-4D7B-A9AC-8AB7C83CC4AC')
BEGIN
INSERT INTO tblRpBase
SELECT *
FROM tblRpBaseDummy
WHERE idrpTable = '2B1A7150-FD1B-4D7B-A9AC-8AB7C83CC4AC'
END
EXECUTE sysGetBalanceBill '1/1/2018 0:0:0.0', '3/26/2018 23:59:59.998',
@Customer, @Store
END
and I'm trying to insert into the temp table like this:
DECLARE @TempTable1 TABLE
(
[InvNum] [INT],
[InvDate] [DATETIME] ,
[Customer] [UNIQUEIDENTIFIER] ,
[CustName] [VARCHAR](255),
[CustLName] [VARCHAR](255),
[InvTotal] [FLOAT]
)
INSERT INTO @TempTable1
SELECT *
FROM Openrowset('SQLNCLI','Server=Name;Database=DbName;Uid=sa;Pwd=Password',
'EXECUTE [DbName1].[dbo].[usrGetBalanceBystore] "00000000-0000-0000-0000-000000000000",
"00000000-0000-0000-0000-000000000000"')
SELECT *
FROM @TempTable1
WHERE CustName = 'ABC'
this line of code return empty table
SELECT *
FROM Openrowset('SQLNCLI','Server=Name;Database=DbName;Uid=sa;Pwd=Password',
'EXECUTE [DbName1].[dbo].[usrGetBalanceBystore] "00000000-0000-0000-0000-000000000000",
"00000000-0000-0000-0000-000000000000"')
if i run only this procedure i can find result
EXECUTE [DbName1].[dbo].[usrGetBalanceBystore] "00000000-0000-0000-0000-000000000000",
"00000000-0000-0000-0000-000000000000"
How can I achieve the above task?