Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6774947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:50:55+00:00 2026-05-26T15:50:55+00:00

I am batching different queries in one SqlCommand stopping the queries batch when I

  • 0

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

The following test code throws ‘too many parameters exception’ even if the number of parameters is less than 2100.

var parametersMax = 2099;

var connection = new SqlConnection(@"Data Source=.;Integrated Security=SSPI;");
connection.Open();

var enumerable = Enumerable.Range(0, parametersMax);

var query = string.Format("SELECT {0}", String.Join(", ", enumerable.Select(s => string.Format("P{0} = @p{0}",s))));

var command = new SqlCommand(query, connection);

foreach(var i in enumerable)
    command.Parameters.Add(string.Format("p{0}",i), i);

// here: command.Parameters.Count is 2099

var reader = command.ExecuteReader(); // throws: 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.

Considering the exception message and the documentation here: http://msdn.microsoft.com/en-us/library/ms143432.aspx I was expecting to be able to have 2100 parameters in one query, but this doesn’t seem to be true. Does anyone know why? Am I missing something?

(I am using Sql Server 2008 R2)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:50:55+00:00Added an answer on May 26, 2026 at 3:50 pm

    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
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have batches and tasks. Upon batching some tasks into another batch I want
I am using IQueryable<> to build up batching queries. I have used views successfully
A lot of sites/articles say 'batch! batch! batch!'. Can someone explain what 'batching' represents
Is it possible to implement batching of multiple stored procedure calls (doing updates/deletes) in
I've been trying to set up some sort of geometry batching for a week
If I configure NHibernate with a batch size of say 20, am I likely
The following code was a proof of concept for a message batching routine. Do
How could this be optimized for speed by batching or other techniques? Its a
What is the best practice for this problem? Is there any batching features built-in?
I am desperately trying to move a document in a document library from one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.