Reputation: 13451
Here is my situation:
I use the SqlCommond 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,
Upvotes: 1
Views: 707
Reputation: 176956
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/
Upvotes: 1
Reputation: 62157
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.
Upvotes: 3