Skip to main content
Dynamics 365
  • 1 min read

How to fix SQL error: “Too many parameters were provided in this RPC request”


Recently we were confronted with a case where we received the following SQL error:

[Microsoft][SQL Native Client][SQL Server]The incoming tabular data stream 
(TDS) remote procedure call (RPC) protocol stream is incorrect. Too many 
parameters were provided in this RPC request. The maximum is 2100.

This error occurs if we are running into a SQL limitation which does not allow more than 2100 parameters in a SQL statement.

Usually it’s a Select statement where AX produces OR clauses with too many parameters like

WHERE RecId = xxxxxx OR RecId = xxxxxy OR RecId = xxxxyx ...

or IN clauses like

WHERE ID IN (xxxxxx,xxxxxy,xxxxyx, ...)

How to find where this select statements are coming from?

In the SQL statement trace log (Administration -> Inquiries – Tab ‘Use’) you will find the stack trace that shows you which method caused the SQL error.

How to fix this problem?

We have to add a forceliterals to the select statement in the relevant method.
Adding a forceliterals should avoid running into the SQL limitation of the 2100 parameters, because the statement is handled differently then.

The related statement could either be an X++ select stament or a X++ Query

X++ Stament
Change code from

select from TableName

to

select forceliterals from TableName

X++ Query
Activate forceliterals on the Query object

query.literals(true);

Get started with Dynamics 365

Drive more efficiency, reduce costs, and create a hyperconnected business that links people, data, and processes across your organization—enabling every team to quickly adapt and innovate.