Since there is no Sqlserver array parameter, what's the best way to proceed?

前端 未结 5 1183
孤独总比滥情好
孤独总比滥情好 2020-12-10 19:23

I need to create multiple records in sqlserver, each with the same value in column A, but with a unique value in column B. I have the values for column B in an array.

<
5条回答
  •  暖寄归人
    2020-12-10 20:01

    If you're wanting to do multiple inserts in a loop in C# - look at TransactionScope. That will let you roll multiple calls to the stored proc into a transaction with rollback capabilities. Another option would be that you could pass your array as XML, and in the stored proc you could shred that XML out to a temp table to use in your proc.

    One last thing you should do is to add Table Valued Parameters to your wish-list of reasons to upgrade to the next version of SQL server. As that wish-list grows, your justification for spending the money to upgrade gets a bit easier to make.

提交回复
热议问题