EOleException error while executing Procedure

By | April 1, 2009

You must have seen this irritating error while executing Stored Procedure from Workflow Action.

EOleException: Procedure or function TESTSP has too many arguments specified.

Solution:

The point is that, when Stored Procedure gets executed from the Workflow action, CRM appends default parameters to the Execute Procedure statement. So we have to declare these parameters at the time of defining Stored Procedure although even we do not use them. These parameters are Entity Name, Entity ID Field Name, Entity Id Value, User Id Value and one output parameter for storing the value is required. You can refer below example for the same:

create proc TESTSP (@EntityName varchar(50),@EntityIdField varchar(50), @IdVal int,@UserId int,@myoutput varchar(50) output)
as
set @myoutput = ’10’
go