You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cannot get results from Stored Procedure that uses INSERT EXEC. #18
EXEC tSQLt.NewTestClass'ReplicateInsertExecIssue';
GO
-- This proc returns a couple of rows
CREATE PROC ReplicateInsertExecIssue.[_DataReturnTable]
ASSELECT CAST('TEST'ASVARCHAR(15)) as col1, CAST(123ASINT) AS col2
UNIONSELECT'TEST', 456
GO
-- This proc returns two tables after using INSERT EXEC
CREATE PROC ReplicateInsertExecIssue.[_DataUsesInsertExec]
ASBEGIN
DECLARE @cachedResults TABLE(col1 VARCHAR(15) NULL , col2 intNULL);
INSERT INTO @cachedResults EXEC ReplicateInsertExecIssue.[_DataReturnTable];
SELECT col1, SUM(col2) AS col2 FROM @cachedResults GROUP BY col1;
SELECT col1, MIN(col2) AS col2 FROM @cachedResults GROUP BY col1;
END;
GO
-- This tries to test the contents returned by the stored proc
CREATE PROC ReplicateInsertExecIssue.[test Replicate INSERT EXEC cannot be nested]
ASBEGIN
CREATE TABLE #expected (col1 VARCHAR(15) NULL , col2 int NULL); INSERT INTO#expected values ('TEST', 123+456);
CREATE TABLE #actual (col1 VARCHAR(15) NULL, col2 int NULL);INSERT INTO#actual EXEC tSQLt.ResultSetFilter 1, 'EXEC ReplicateInsertExecIssue._DataUsesInsertExec';
EXEC tSQLt.AssertEqualsTable'#expected', '#actual';
END;
GO
EXEC tSQLt.Run'ReplicateInsertExecIssue';
go
Activity
The change addresses the issue with testing stored procedures that co…
The change addresses the issue with testing stored procedures that co…
Add procedure ResultSetInsert