Update Multiple records in SQL Server
Here is my situation:
I use the SqlCo开发者_C百科mmond to update some records in the SQL Server in a ASP.NET web site. Users can choose which records they want to update. Sometimes they may choose 40 or 60 records to update at a time.Is there any good way to do it? I do not want to do like it
foreach(string ID in List)
{
Update here
}
Best Regards,
You can send one SQL string ith all the update statements together. Nothing says a SQL "round trip" can not execute multiple statements or even multiple batches.
yes we can do thing in one round tip. create xml string of the selected id and pass to the procedure as and Varchar(max) argument.
and in sql part use openXml
and update data.
check th post : http://www.sqlservercentral.com/articles/OpenXML/usingopenxml/1881/
精彩评论