How to perform batch update in Sql through C# code

后端 未结 4 460
北恋
北恋 2020-12-29 09:39

I want to update multiple rows like below

update mytable set s_id = {0} where id = {1}

(Here s_id is evaluated based on some

4条回答
  •  醉梦人生
    2020-12-29 10:11

    Create a set of those updates (with the id's filled in), separate them by semicolon in one string, set the resulting string to a SqlCommand's CommandText property, then call ExecuteNonQuery().

提交回复
热议问题