How to add more than 10000 parameters to a single sql command

后端 未结 2 1843
滥情空心
滥情空心 2021-01-14 09:31

I want to add more than 10000 parameters to a single sql command. How it possible? As far i know 2100 parameters a single sql command.

相关标签:
2条回答
  • 2021-01-14 09:45

    I think you step back to the "why" rather than jumping right to the "how". It sounds like maybe you are doing some huge insert/update, in which case a more appropriate solution would be table-valued-parameters.

    Other options include:

    • passing in xml and using SQL server to parse the xml (it is quite good at this)
    • loading data first with something like SqlBulkCopy into a staging table, then executing a command (raw TSQL or a SPROC) to push the data from the staging table into the transactional tables
    • if it is just a list of ids, write a "split" function (udf) at the server and pass in a [n]varchar(max)
    • batch the operations into a number of more sane commands

    You really don't want to do something with 10k parameters on one command; that way madness lies.

    0 讨论(0)
  • 2021-01-14 10:00

    You can't. SQL Server supports a maximum of 2100 parameters.

    Your only option is to generate a SQL string containing all those parameter values.

    Incidentally, SQL CE does not have this limitation.

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