Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.databases.ms-sqlserver > #734
| From | Erland Sommarskog <esquel@sommarskog.se> |
|---|---|
| Newsgroups | comp.databases.ms-sqlserver |
| Subject | Re: trying to replace multiple update statements with one update |
| Date | 2011-10-04 23:14 +0200 |
| Organization | Erland Sommarskog |
| Message-ID | <Xns9F74EC8288738Yazorman@127.0.0.1> (permalink) |
| References | <a1a10e66-2ba9-4940-b933-b02887254a04@t16g2000yqm.googlegroups.com> |
migurus (migurus@yahoo.com) writes: > SQL 2005, there is a table with some 20,000 rows updated quite > frequently, estimates are 2000 updates per minute. Many updates affect > several records at once, so each update touches approximately 10 - 15 > records. > > I am trying to come up with solution that avoids multiple updates with > one update, thinking that it is less load on the db locking etc... The > idea is for the app to declare a variable type of table, populate it > with key - value pairs and then issue one update statement that will > join the in memory table with the table. Sounds like an excellent idea! The only hickup is that SQL 2005 does not support table-valued parameters; you need SQL 2008 for that. However, rather than passing a TVP, you can pass the values in an XML document, and then update the table from that document. See http://www.sommarskog.se/arrays-in-sql-2005.html#XML for an introduction. -- Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se Links for SQL Server Books Online: SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
Back to comp.databases.ms-sqlserver | Previous | Next — Previous in thread | Next in thread | Find similar
trying to replace multiple update statements with one update migurus <migurus@yahoo.com> - 2011-10-03 18:11 -0700
Re: trying to replace multiple update statements with one update Erland Sommarskog <esquel@sommarskog.se> - 2011-10-04 23:14 +0200
Re: trying to replace multiple update statements with one update --CELKO-- <jcelko212@earthlink.net> - 2011-10-05 09:21 -0700
Re: trying to replace multiple update statements with one update Erland Sommarskog <esquel@sommarskog.se> - 2011-10-05 23:44 +0200
csiph-web