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

后端 未结 2 1844
滥情空心
滥情空心 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.

提交回复
热议问题