I have a SQL Server stored procedure that normally runs fine. However, for one record as I walk through the stored procedure it is “skipping” a line without running it.
if not exists ( select * ... ) begin
exec @Result = InsertRecord_A @AccountNo, @ID, @EventID;
if @Result <> 0 return @Result;
-- Do something else
insert into ...
select ...
end
That line, exec @Result... is being skipped in this case. Normally it launches the procedure InsertRecord_A but I can’t get it to run on this record.
Any ideas?
Update: There is the following error message:
Msg 201, Level 16, State 4, Procedure InsertRecord_A, Line 0
Procedure or function 'InsertRecord_A' expects parameter '@EventID', which was not supplied.
What is odd about the error message, is when walking through it, @EventID shows it has a value of 460 which is correct.
Try explicitly setting the parameters to the correct values, rather than passing them by ordinal position and hoping they’re in the correct order:
This is of course assumes that your
InsertRecord_Aprocedure does take 3 procedures with the same names as your variables.If you’re not sure about this, you can run
exec sp_help InsertRecord_Aor look in thesys.parameterstable to check what they’re called.