samedi 31 janvier 2015

Column name or number of supplied values does not match table definition - with correct parrameters


I am executing a stored procedure in a while loop (approximately 100 times). This takes 20 seconds.


The problem is that at some point, I receives this error: Column name or number of supplied values does not match table definition


When I say at some point, I mean that most of the executes are successfully.


But this is not the real problem because the parameters I sent to the stored procedure are 100% OK.


I even catched the error and saw the parameters that were sent and execute the stored procedure without a while loop and it succeeded. Moreover, I saw that every time the error catches different parameters (the execute to the stored procedure fails to different parameters).


Could it be because memory issues?


My code is something like this:



DECLARE @p1 INT = 1;

CREATE TABLE #MyTable
(
Column1 INT,
Column2 NVARCHAR(255)
);

WHILE (@p1 < 100)
BEGIN
INSERT #MyTable
EXEC dbo.MyStoredProcedure @p1;

SET @p1 = @p1 + 1;
END

SELECT * FROM #MyTable;

IF OBJECT_ID('tempdb..#MyTable') IS NOT NULL DROP TABLE #MyTable;




Aucun commentaire:

Enregistrer un commentaire