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
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
The text was updated successfully, but these errors were encountered:
The ResultSetInsert procedure works like ResultSetFilter but insert
results into a table which name is passed as third paramter,
`@Table`.
This works around the nested insert exec issue (tSQLt-org#18).
This is an alternative and original implementation of PR tSQLt-org#19.
Signed-off-by: Paul Guyot <[email protected]>
At the bottom is a tSQLt test that replicates the "INSERT EXEC statement cannot be nested.” issue.
This has been reported a while ago the consensus is this requires a CLR procedure to work around SQL server limitations.
Replication
The text was updated successfully, but these errors were encountered: