SqlCommand maximum parameters exception at 2099 parameters

前端 未结 1 1155
执念已碎
执念已碎 2021-02-19 00:41

I am batching different queries in one SqlCommand stopping the queries batch when I hit the 2100 parameter limit. If my batch has 2100 or 2099 parameters I still get the excepti

1条回答
  •  忘了有多久
    2021-02-19 01:00

    The command sent to SQL Server is

    exec sp_executesql 
              N'SELECT P0 = @p0, P1 = @p1, P2 = @p2...',
              N'@p0 int,@p1 int,@p2 int...',
              @p0=0,@p1=1,@p2=2...
    

    Note that 2 of the parameter slots in the call to sp_executesql are taken up with the NVARCHAR strings for query text and the parameter definitions thus "only" leaving 2,098 free for you to use.

    0 讨论(0)
提交回复
热议问题