SQL query does not take values ​​more than 2100

SELECT MachineID, MachineName, count(ID) as Total, sum(Size) as TotalSize 
  FROM Files 
  join Machines on Files.MachineID = Machines.MachineID 
 Where Files.MachineID In(sql.Append(string.Format("@MachineId{0}", i));
 group by Files.MachineID,MachineName

Now, when the machinId counter is less than 2100, the request is executed, and if it goes beyond 2100, an error occurs Error:

Invalid tabular data stream (TDS) remote procedure protocol (RPC) protocol flow. Too many parameters were provided in this RPC request. Maximum 2100.

how can I increase the limit or just not get this error .. and put the values ​​in a gridview thanks ..

+3
source share
2 answers

, sql, "IN" ( , , IN-), DB , IN. , , 2100. , Oracle 1000

+4

. SQL Server WHERE

...WHERE CHARINDEX(':' + <: delimited list of machine IDs> + ':', 
       ':' + CAST(Files.MachineID as VARCHAR(10)) + ':') <> 0

The: , 100 1001, 1002, 2100 ..

...WHERE CHARINDEX(':1000:1001:1002:1005:', 
       ':' + CAST(Files.MachineID as VARCHAR(10)) + ':') <> 0
0

Source: https://habr.com/ru/post/1750190/


All Articles