1. 程式人生 > >Exception: Too many parameters were provided in this RPC request. The maximum

Exception: Too many parameters were provided in this RPC request. The maximum

procedure protocol provided request stream

Exception: Too many parameters were provided in this RPC request. The maximum is 2100.

[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.


SQL語句的報錯

如果是SELECT查詢OR條件語句形如:SELECT * FROM tablename WHERE x1 OR x2 OR x3 OR x4 OR ... OR x2101,OR條件個數超過2100就會報錯,可以改為UNION ALL。

如果是SELECT查詢IN條件語句形如: SELECT * FROM tablename WHERE columnname IN (1,2,3,4,5, ........ , 2101 ),IN參數個數超過2100,會報上面的錯誤。可以創建臨時表,將這些數據寫入臨時表,再關聯。

--Create new table
Create Table temp (myvalues uniqueidentifier)

-- Join new table with your table
SELECT t1.*
FROM tablename t1
JOIN temp t2 ON t1.myvalues = t2.myvalues

存儲過程和函數的報錯

對於存儲過程和函數,參數最大個數為2100

https://docs.microsoft.com/en-us/sql/sql-server/maximum-capacity-specifications-for-sql-server

Exception: Too many parameters were provided in this RPC request. The maximum